* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    background-color: #050508;
    color: #ffffff;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    height: 100svh;
    overflow: hidden;
    position: relative;
}

/* 16:9 반응형 표준 컨테이너 */
.responsive-16-9 {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 56.25vw;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: 100svh;
    max-width: 177.78vh;
    max-width: 177.78dvh;
    container-type: size;
}

#lobby-wrapper { overflow: hidden; }

/* 메인 로비 */
#lobby-carousel-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

.carousel-slide {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover; 
    background-position: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}
.carousel-slide.active { opacity: 1; }

.lobby-overlay-vignette {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.7) 100%),
                linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.1) 30%, rgba(0,0,0,0.85) 100%);
    z-index: 2;
    pointer-events: none;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 8cqh; height: 10cqh;
    border-radius: 1cqh;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3cqh;
    transition: all 0.3s ease;
}
.carousel-arrow:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}
.carousel-arrow.left { left: 2cqh; }
.carousel-arrow.right { right: 2cqh; }

.lobby-header-title {
    position: absolute;
    top: 3.5cqh; 
    left: 5cqh;
    z-index: 10;
    text-align: left;
}

.lobby-header-title h1 {
    font-size: 4.8cqh;
    font-weight: 900;
    letter-spacing: -0.2cqh;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    color: #ffffff;
}

.lobby-header-title .rate-info {
    font-size: 2cqh;
    color: #b0b0cb;
    margin-top: 0.6cqh;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.rate-6 { color: #ffffff; text-shadow: 0 0 8px #00e5ff, 0 0 16px #ffffff; font-weight: 900; }
.rate-5 { color: #ffd700; font-weight: bold; }
.rate-4 { color: #d370ff; font-weight: bold; }
.rate-3 { color: #4cb2ff; font-weight: bold; }

/* 로비 우측 상단 토글 버튼 */
.lobby-carousel-toggle-btn {
    position: absolute;
    top: 3.5cqh;
    right: 5cqh;
    z-index: 15;
    background: rgba(18, 22, 35, 0.88);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.45);
    padding: 1.1cqh 2.2cqh;
    font-size: 1.9cqh;
    font-weight: 800;
    border-radius: 2.5cqh;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    display: inline-flex;
    align-items: center;
    gap: 0.6cqh;
    white-space: nowrap;
    backdrop-filter: blur(8px);
}
.lobby-carousel-toggle-btn:hover {
    background: #ffd700;
    color: #0b0d14;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.7);
    transform: translateY(-2px);
}
.lobby-carousel-toggle-btn.team-mode {
    background: linear-gradient(135deg, #1d3557, #111e38);
    color: #00e5ff;
    border-color: #00e5ff;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.6);
}

/* 마일리지 교환 위젯 */
.lobby-mileage-box {
    position: absolute;
    bottom: 2cqh;
    left: 5cqh;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.6cqh;
    background: rgba(14, 17, 28, 0.88);
    border: 1px solid rgba(255, 215, 0, 0.35);
    border-radius: 1.2cqh;
    padding: 1.2cqh 1.6cqh;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    width: 25cqh;
}

.mileage-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.5cqh;
    font-weight: bold;
}
.mileage-label { color: #ffffff; }
.mileage-points { color: #ffd700; }

.mileage-progress-bar {
    width: 100%;
    height: 0.8cqh;
    background-color: #1a1e30;
    border-radius: 0.4cqh;
    overflow: hidden;
    margin: 0.2cqh 0;
}
.mileage-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ff9900);
    transition: width 0.3s ease;
}

.mileage-exchange-btn {
    background: #252838;
    color: #8890aa;
    border: 1px solid #3d425c;
    padding: 0.8cqh 1.2cqh;
    font-size: 1.5cqh;
    font-weight: 800;
    border-radius: 0.8cqh;
    cursor: not-allowed;
    transition: all 0.25s ease;
    white-space: nowrap;
    text-align: center;
}
.mileage-exchange-btn.active {
    background: linear-gradient(135deg, #ffd700, #b8860b);
    color: #0b0d14;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    animation: mileageGlow 1.5s infinite alternate ease-in-out;
}
.mileage-exchange-btn.active:hover {
    background: linear-gradient(135deg, #ffe240, #d49a00);
    transform: translateY(-2px);
}
@keyframes mileageGlow {
    0% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.3); }
    100% { box-shadow: 0 0 16px rgba(255, 215, 0, 0.8); }
}

/* 하단 메뉴 바 */
.bottom-menu-wrapper {
    position: absolute;
    bottom: 2cqh;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    max-width: 110cqh;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.6cqh;
}

.pickup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8cqh;
}
.pickup-label {
    font-size: 1.8cqh;
    color: #ffd700;
    letter-spacing: 0.2cqh;
    font-weight: 800;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.pickup-slots { display: flex; gap: 8px; align-items: center; }

.pickup-slot-divider {
    width: 2px;
    height: 7cqh;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

.pickup-slot {
    width: 10.5cqh;
    height: 10.5cqh;
    border: 1px dashed rgba(255, 255, 255, 0.35);
    border-radius: 1.5cqh;
    cursor: pointer;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}
.pickup-slot.slot-5 { border-color: rgba(255, 215, 0, 0.45); }
.pickup-slot.slot-5:hover { border-color: #ffd700; background-color: rgba(255, 215, 0, 0.15); }

.pickup-slot.slot-4 { border-color: rgba(211, 112, 255, 0.45); }
.pickup-slot.slot-4:hover { border-color: #d370ff; background-color: rgba(211, 112, 255, 0.15); }

.pickup-slot .plus-icon {
    font-size: 3.5cqh;
    color: rgba(255,255,255,0.4);
    font-weight: 300;
    pointer-events: none;
}
.slot-badge {
    position: absolute;
    bottom: 4px; right: 6px;
    font-size: 1.3cqh;
    font-weight: 900;
    pointer-events: none;
    text-shadow: 0 1px 3px #000;
}
.slot-badge-5 { color: #ffd700; }
.slot-badge-4 { color: #d370ff; }

.lobby-btn-row { display: flex; width: 100%; gap: 8px; }

.gacha-btn {
    background: rgba(20, 20, 30, 0.85);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 1.8cqh 2.8cqh; 
    font-size: 2.1cqh;
    font-weight: 700;
    border-radius: 1cqh;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    text-align: center;
    display: inline-block;
    flex: 1;
    white-space: nowrap;
}
.gacha-btn:hover {
    background: rgba(40, 40, 60, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}
.gacha-btn.accent {
    background: linear-gradient(135deg, #ffd700, #b8860b);
    color: #0f0f15;
    border: none;
    font-weight: 800;
}
.gacha-btn.accent:hover {
    background: linear-gradient(135deg, #ffe240, #d49a00);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}
.gacha-btn.team-btn {
    background: linear-gradient(135deg, #2b3a67, #192238);
    border-color: #5d75b3;
}
.gacha-btn.team-btn:hover {
    background: linear-gradient(135deg, #3a4f8c, #232f4f);
    border-color: #8fa5e3;
}
.gacha-btn.danger {
    background: #3d1414;
    border-color: #662222;
    color: #ff9999;
}
.gacha-btn.danger:hover {
    background: #5a1e1e;
    border-color: #993333;
    color: #ffffff;
}

/* 6인 유닛 배치 화면 & 10파티 네비게이터 */
#formation-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    height: 100dvh; height: 100svh;
    background-color: #06070c;
    z-index: 220;
    display: none;
}
#formation-overlay.active { display: block; }
.formation-viewport { overflow: hidden; }

.formation-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 40%, rgba(30, 40, 75, 0.4) 0%, rgba(5, 7, 15, 0.95) 85%);
    z-index: 1;
    pointer-events: none;
}

.formation-content {
    position: relative;
    z-index: 5;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1.5cqh 2cqh 2cqh 2cqh;
}

.formation-header-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0.1cqh;
}

.formation-preset-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 170cqh;
}

.preset-nav-bar {
    display: flex;
    align-items: center;
    gap: 1cqh;
    background: #141824;
    border: 1px solid #2a3550;
    border-radius: 0.8cqh;
    padding: 0.3cqh 0.8cqh;
}
.preset-nav-arrow {
    background: transparent;
    border: none;
    color: #8fa0c2;
    font-size: 2cqh;
    cursor: pointer;
    padding: 0.2cqh 0.8cqh;
    transition: color 0.2s, transform 0.1s;
}
.preset-nav-arrow:hover { color: #00e5ff; transform: scale(1.15); }
.preset-current-indicator {
    font-size: 1.8cqh;
    font-weight: 800;
    color: #ffffff;
    min-width: 13cqh;
    text-align: center;
    letter-spacing: 0.1cqh;
}

.title-codex-open-btn {
    background: #201e14;
    color: #ffd700;
    border: 1px solid #5c4e1e;
    padding: 0.7cqh 1.8cqh;
    font-size: 1.7cqh;
    font-weight: 700;
    border-radius: 0.6cqh;
    cursor: pointer;
    transition: all 0.2s;
}
.title-codex-open-btn:hover { background: #383015; border-color: #ffd700; }

.formation-title-fixed-box {
    height: 3.4cqh;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 95%;
}

.formation-active-title {
    font-size: 2.2cqh;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6), 0 2px 4px #000;
    letter-spacing: 0.1cqh;
    animation: titlePulse 2s infinite alternate ease-in-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.formation-active-title.show { opacity: 1; visibility: visible; }

@keyframes titlePulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.02); filter: brightness(1.2); }
}

#formation-status-subtext {
    font-size: 1.4cqh;
    color: #a0a5c0;
    height: 2cqh;
    line-height: 2cqh;
    margin: 0;
}

.formation-slots-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.4cqh;
    width: 100%;
    max-width: 170cqh;
    margin: 0 auto;
}

.unit-slot {
    width: 26cqh;
    height: 39cqh;
    aspect-ratio: 2 / 3;
    border-radius: 1.4cqh;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 18, 28, 0.7);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    touch-action: pan-y;
}
.unit-slot:hover {
    border-color: #ffd700;
    transform: translateY(-4px);
    background: rgba(255, 215, 0, 0.08);
}
.unit-slot.filled { border-style: solid; background-color: #0b0d14; cursor: grab; }
.unit-slot.filled:active { cursor: grabbing; }

.unit-slot.border-6 { border-color: #ffffff; box-shadow: 0 0 20px rgba(0, 229, 255, 0.6); }
.unit-slot.border-5 { border-color: #ffd700; box-shadow: 0 0 15px rgba(255, 215, 0, 0.3); }
.unit-slot.border-4 { border-color: #d370ff; box-shadow: 0 0 15px rgba(211, 112, 255, 0.3); }
.unit-slot.border-3 { border-color: #4cb2ff; }

.unit-slot.dragging {
    opacity: 0.35 !important;
    transform: scale(0.92) !important;
    border: 2px dashed #ffd700 !important;
}
.unit-slot.drag-over {
    transform: scale(1.06) translateY(-6px) !important;
    border-color: #00e5ff !important;
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.8) !important;
}
.unit-slot.touch-swap-selected {
    border-color: #00e5ff !important;
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.9) !important;
    transform: translateY(-8px) scale(1.04) !important;
    animation: touchPulse 1s infinite alternate ease-in-out;
}

.unit-slot-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
    pointer-events: none;
}
.unit-slot-vignette {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0) 100%);
    z-index: 2;
    pointer-events: none;
}

.unit-slot-info {
    position: absolute;
    bottom: 1.6cqh;
    left: 1cqh; right: 1cqh;
    z-index: 4;
    text-align: center;
    pointer-events: none;
}
.unit-slot-stars { font-size: 1.6cqh; color: #ffd700; line-height: 1; }
.unit-slot-stars.stars-6 { color: #ffffff; text-shadow: 0 0 8px #00e5ff; }

.unit-slot-name {
    font-size: 1.8cqh;
    font-weight: 800;
    color: #ffffff;
    margin-top: 0.3cqh;
    white-space: normal;
    word-break: keep-all;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 2px 4px #000;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.unit-slot-empty-icon { font-size: 4.5cqh; color: rgba(255, 255, 255, 0.3); font-weight: 200; pointer-events: none; }
.unit-slot-empty-label { font-size: 1.6cqh; color: rgba(255, 255, 255, 0.4); margin-top: 0.8cqh; font-weight: bold; pointer-events: none; }

.slot-remove-btn {
    position: absolute;
    top: 1cqh; right: 1cqh;
    width: 3.6cqh; height: 3.6cqh;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8cqh;
    font-weight: bold;
    cursor: pointer;
    z-index: 6;
    transition: all 0.2s;
}
.slot-remove-btn:hover { background: #cc2222; border-color: #ff5555; transform: scale(1.1); }
.formation-footer-area { display: flex; gap: 15px; }

/* 칭호 도감 모달 */
#title-codex-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    height: 100dvh; height: 100svh;
    background-color: rgba(5, 7, 15, 0.92);
    z-index: 260;
    display: none;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
}
#title-codex-overlay.active { display: flex; }

.title-codex-box {
    background-color: #0d0f18;
    border: 1px solid #2d3550;
    border-radius: 12px;
    padding: 22px 24px;
    width: 92%;
    max-width: 620px;
    max-height: 88vh;
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    margin: auto;
}

.codex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #23283d;
    padding-bottom: 10px;
    flex-shrink: 0;
}
.codex-header h2 { font-size: 1.3rem; font-weight: 800; color: #ffd700; }

.codex-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 6px;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}
.codex-item {
    background: #141724;
    border: 1px solid #232a40;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.codex-item.unlocked {
    border-color: #ffd700;
    background: #1a1e30;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.15);
}

.codex-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.codex-item-name { font-size: 1rem; font-weight: bold; color: #ffd700; }

.codex-deploy-btn {
    background: linear-gradient(135deg, #1d3557, #111e38);
    color: #00e5ff;
    border: 1px solid #00e5ff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.codex-deploy-btn:hover {
    background: #00e5ff;
    color: #0b0d14;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

.codex-clue-btn {
    background: linear-gradient(135deg, #0d3b66, #001f3f);
    color: #70d6ff;
    border: 1px solid #00b4d8;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.codex-clue-btn:hover {
    background: #00b4d8;
    color: #030816;
    box-shadow: 0 0 10px rgba(0, 180, 216, 0.7);
}

.codex-item-members { font-size: 0.8rem; }
.codex-footer { text-align: right; flex-shrink: 0; padding-top: 4px; }

/* 잎사귀 각성 연출 */
#summon-cutscene-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    height: 100dvh; height: 100svh;
    background-color: #030306;
    z-index: 180;
    display: none;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#cutscene-responsive-wrapper {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw; height: 56.25vw;
    max-height: 100vh; max-height: 100dvh; max-height: 100svh;
    max-width: 177.78vh; max-width: 177.78dvh;
    container-type: size;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.glitch-anim { animation: glitchShake 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) both !important; }

.cutscene-aura-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1; opacity: 0; transition: opacity 1.5s ease;
}
.cutscene-aura-bg.active { opacity: 1; }
.aura-theme-6 {
    background: radial-gradient(circle at 50% 50%, rgba(0, 240, 255, 0.4) 0%, rgba(130, 40, 255, 0.3) 40%, rgba(5, 5, 18, 0.98) 85%);
    animation: cosmicAuraSpin 5s infinite linear;
}
.aura-theme-5 {
    background: radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.4) 0%, rgba(255, 50, 150, 0.25) 35%, rgba(0, 220, 255, 0.2) 65%, #030306 100%);
    animation: auraColorSpin 6s infinite linear;
}
.aura-theme-4 {
    background: radial-gradient(circle at 50% 50%, rgba(190, 70, 255, 0.4) 0%, rgba(80, 20, 150, 0.25) 50%, #030306 100%);
    animation: auraPulsePurple 3s infinite alternate ease-in-out;
}
.aura-theme-3 { background: radial-gradient(circle at 50% 50%, rgba(50, 150, 255, 0.35) 0%, rgba(10, 40, 110, 0.2) 50%, #030306 100%); }

.leaf-stage {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45cqh; height: 45cqh;
}
.leaf-halo {
    position: absolute;
    width: 32cqh; height: 32cqh;
    border-radius: 50%;
    filter: blur(35px);
    z-index: -1;
    transition: all 1.5s ease;
    opacity: 0.8;
}
.halo-mono { background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, rgba(200, 200, 220, 0.05) 50%, transparent 70%); }
.halo-dyed-3 { background: radial-gradient(circle, rgba(76, 178, 255, 0.8) 0%, rgba(30, 90, 200, 0.4) 50%, transparent 70%); }
.halo-dyed-4 {
    background: radial-gradient(circle, rgba(211, 112, 255, 0.85) 0%, rgba(130, 30, 200, 0.45) 50%, transparent 70%);
    animation: haloPulsePurple 2s infinite alternate ease-in-out;
}
.halo-dyed-5 {
    background: radial-gradient(circle, rgba(255, 215, 0, 0.9) 0%, rgba(255, 60, 180, 0.6) 45%, rgba(0, 220, 255, 0.4) 70%, transparent 100%);
    animation: haloPulseRainbow 1.4s infinite alternate ease-in-out;
}
.halo-dyed-6 {
    background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(0, 240, 255, 0.8) 40%, rgba(160, 40, 255, 0.5) 70%, transparent 100%);
    animation: haloPulseCosmic 1.1s infinite alternate ease-in-out;
}

@keyframes leafEnter {
    0% { transform: scale(0.1) rotate(-15deg); opacity: 0; }
    60% { transform: scale(1.08) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes leafPulseCosmic {
    0% { transform: scale(1); filter: drop-shadow(0 0 15px #00f0ff); }
    100% { transform: scale(1.08); filter: drop-shadow(0 0 35px #ffffff) drop-shadow(0 0 50px #00f0ff); }
}

.leaf-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
    opacity: 1;
    animation: leafEnter 1.2s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.mystic-leaf-svg { width: 26cqh; height: 33cqh; overflow: visible !important; }
.leaf-body { stroke-width: 2.2; transition: fill 1.2s ease, stroke 1.2s ease; }
.leaf-vein { stroke-width: 1.8; stroke-linecap: round; fill: none; transition: stroke 1.2s ease; }
.leaf-monochrome .leaf-body { fill: url(#grad-mono); stroke: rgba(255, 255, 255, 0.35); }
.leaf-monochrome .leaf-vein { stroke: rgba(255, 255, 255, 0.2); }
.leaf-dyed-3 .leaf-body { fill: url(#grad-blue); stroke: #75c6ff; }
.leaf-dyed-3 .leaf-vein { stroke: #d4efff; }
.leaf-dyed-4 .leaf-body { fill: url(#grad-purple); stroke: #e29bff; }
.leaf-dyed-4 .leaf-vein { stroke: #f9e3ff; }
.leaf-dyed-5 .leaf-body { fill: url(#grad-rainbow); stroke: #ffd700; }
.leaf-dyed-5 .leaf-vein { stroke: #ffffff; }
.leaf-dyed-6 .leaf-body { fill: url(#grad-cosmic); stroke: #ffffff; filter: drop-shadow(0 0 15px #00f0ff); }
.leaf-dyed-6 .leaf-vein { stroke: #ffffff; filter: drop-shadow(0 0 8px #ffffff); }
.leaf-dyed-6 { animation: leafPulseCosmic 1.2s infinite alternate ease-in-out; }

/* 가챠 연출 오버레이 */
#reveal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    height: 100dvh; height: 100svh;
    background-color: #000;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
}
#reveal-overlay.active { opacity: 1; pointer-events: auto; }

.tap-to-continue {
    position: absolute;
    bottom: 6cqh; right: 6.5cqh;
    font-size: 2.2cqh;
    color: rgba(255, 255, 255, 0.6);
    animation: pulse 1.5s infinite;
    z-index: 120;
    letter-spacing: 0.2cqh;
    transition: opacity 0.5s ease;
    opacity: 0;
}
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.gacha-skip-btn {
    position: absolute;
    top: 4cqh; right: 6cqh;
    z-index: 130; 
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5cqh 3.2cqh;
    border-radius: 3cqh;
    font-size: 2.4cqh;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: none; 
}
.gacha-skip-btn:hover { background: rgba(255, 255, 255, 0.15); border-color: #ffd700; }

/* 대사 화면 */
#quote-screen {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%; height: 100%;
    padding: 40px;
    background-color: #050505;
    z-index: 105;
    text-align: center;
    position: relative;
}
#quote-screen.quote-6-bg {
    background: radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.15) 0%, rgba(90, 0, 200, 0.2) 40%, #030308 90%);
}
.quote-badge-6 {
    font-size: 1.9cqh;
    color: #00ffff;
    letter-spacing: 0.4cqh;
    font-weight: 900;
    margin-bottom: 2cqh;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #ffffff;
    display: none;
}
.quote-text {
    font-size: 3.5cqh;
    font-weight: 700;
    color: #ffd700;
    line-height: 1.6;
    word-break: keep-all;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    opacity: 0;
    transform: translateY(2cqh);
    animation: fadeInUp 0.8s forwards ease-out;
    max-width: 85%;
}
.quote-text.quote-6-style { color: #ffffff; text-shadow: 0 0 15px #00e5ff, 0 0 30px #ffffff, 0 0 50px #8a2be2; }

#card-screen { display: none; width: 100%; height: 100%; position: relative; z-index: 110; }
.fullscreen-card { width: 100%; height: 100%; background-size: contain; background-repeat: no-repeat; background-position: center; opacity: 0; }
.fullscreen-card.show { opacity: 1; }

.card-vignette {
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 35%;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
    z-index: 5;
}
.card-info-overlay {
    position: absolute;
    bottom: 7.5cqh; left: 6.5cqh;   
    z-index: 10; text-align: left;
}
.clean-outer-stroke {
    position: relative;
    display: inline-block;
    line-height: 1.1;
    color: #000000;
    -webkit-text-stroke: 0.6cqh #000000; 
}
.clean-outer-stroke::after {
    content: attr(data-text);
    position: absolute;
    left: 0; top: 0; width: 100%; height: 100%;
    -webkit-text-stroke: 0px !important;
    z-index: 2;
}

.card-stars { font-size: 5cqh; margin-bottom: 0px; letter-spacing: 0.4cqh; }
.card-stars.card-stars-6::after { color: #ffffff; text-shadow: 0 0 12px #00e5ff, 0 0 25px #ffffff; }
.card-stars.card-stars-normal::after { color: #ffd700; }
.card-skin-name { font-size: 8cqh; font-weight: 900; letter-spacing: -0.1cqh; }
.card-skin-name::after { color: #ffffff; }
.new-label-overlay { font-size: 3cqh; color: #ff3b30; margin-bottom: 0.5cqh; letter-spacing: 0.2cqh; font-weight: 900; }
.new-label-overlay::after { color: #ff3b30; }

.glow-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }
.glow-6 { box-shadow: inset 0 0 60px rgba(255, 255, 255, 0.7), inset 0 0 120px rgba(0, 229, 255, 0.5); }
.glow-5 { box-shadow: inset 0 0 45px rgba(255, 215, 0, 0.45); }
.glow-4 { box-shadow: inset 0 0 40px rgba(211, 112, 255, 0.45); }
.glow-3 { box-shadow: inset 0 0 30px rgba(76, 178, 255, 0.3); }

#flash-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 150; opacity: 0; }
.flash-active-6 { animation: flash-cosmic 0.7s ease-out forwards; }
.flash-active-5 { animation: flash-gold 0.6s ease-out forwards; }
.flash-active-4 { animation: flash-purple 0.6s ease-out forwards; }
.flash-active-3 { animation: flash-blue 0.6s ease-out forwards; }

@keyframes flash-cosmic {
    0% { background-color: #000000; opacity: 1; }
    30% { background-color: #000000; opacity: 1; }
    40% { background-color: #ffffff; opacity: 1; }
    100% { background-color: rgba(0, 229, 255, 0); opacity: 0; }
}
@keyframes flash-gold { 0% { background-color: rgba(255, 215, 0, 0.5); opacity: 1; } 100% { background-color: rgba(255, 215, 0, 0); opacity: 0; } }
@keyframes flash-purple { 0% { background-color: rgba(211, 112, 255, 0.5); opacity: 1; } 100% { background-color: rgba(211, 112, 255, 0); opacity: 0; } }
@keyframes flash-blue { 0% { background-color: rgba(76, 178, 255, 0.5); opacity: 1; } 100% { background-color: rgba(76, 178, 255, 0); opacity: 0; } }

/* 도감 & 결과 통합 화면 */
#collection-overlay,
#summary-overlay {
    position: absolute;
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background-color: #08080c;
    z-index: 250;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; 
    padding: 30px 20px 140px 20px;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important; 
}
#collection-overlay.active,
#summary-overlay.active { display: flex !important; }

.collection-header,
.collection-search-bar,
.collection-category-panel,
.collection-filter-bar,
.collection-grid,
.collection-pagination,
.collection-footer-btns { flex-shrink: 0 !important; }

.collection-header {
    width: 100%; max-width: 800px;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.collection-title { font-size: 1.4rem; font-weight: 800; }
.collection-progress { font-size: 0.9rem; color: #ffd700; }

/* 검색창 & 분류 토글 버튼 */
.collection-search-bar {
    width: 100%; max-width: 800px;
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
#collection-search-input {
    flex: 1;
    background: #141420;
    border: 1px solid #2d2d42;
    border-radius: 6px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}
#collection-search-input:focus { border-color: #ffd700; }

.search-clear-btn {
    background: #202030;
    border: 1px solid #3d3d5c;
    color: #aaa;
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.search-clear-btn:hover { color: #fff; background: #31314d; }

.category-toggle-btn {
    background: #192033;
    border: 1px solid #33446a;
    color: #00e5ff;
    border-radius: 6px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.category-toggle-btn:hover,
.category-toggle-btn.active {
    background: #00e5ff;
    color: #050a16;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

/* 소속/팩션 분류 체크박스 패널 */
.collection-category-panel {
    width: 100%; max-width: 800px;
    background: #101422;
    border: 1px solid #28334e;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
    animation: slideDownPanel 0.25s ease-out;
}

@keyframes slideDownPanel {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.category-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}
.category-panel-title {
    font-size: 0.85rem;
    font-weight: bold;
    color: #ffd700;
}
.category-reset-btn {
    background: #251a24;
    border: 1px solid #5a3050;
    color: #ff99bb;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.category-reset-btn:hover {
    background: #4a2538;
    color: #ffffff;
    border-color: #ff3377;
}

.category-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

.category-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #161c2d;
    border: 1px solid #232d47;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.78rem;
    color: #b5c3e0;
    transition: all 0.2s ease;
    user-select: none;
}
.category-checkbox-item:hover {
    background: #202942;
    border-color: #405480;
    color: #ffffff;
}
.category-checkbox-item.checked {
    background: rgba(255, 215, 0, 0.15);
    border-color: #ffd700;
    color: #ffd700;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.25);
}
.category-custom-box {
    width: 15px; height: 15px;
    border: 1.5px solid #4a5a80;
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 900;
    flex-shrink: 0;
}
.category-checkbox-item.checked .category-custom-box {
    background: #ffd700;
    border-color: #ffd700;
    color: #0b0d14;
}

.collection-filter-bar {
    width: 100%; max-width: 800px;
    display: flex; gap: 6px; margin-bottom: 20px;
    overflow-x: auto; padding-bottom: 4px;
    -ms-overflow-style: none; scrollbar-width: none; 
}
.collection-filter-bar::-webkit-scrollbar { display: none !important; }

.filter-tab-btn {
    background: #181825; color: #aaa;
    border: 1px solid #2d2d3f;
    padding: 8px 14px; border-radius: 4px;
    font-size: 0.8rem; cursor: pointer;
    white-space: nowrap; transition: all 0.2s ease;
}
.filter-tab-btn.active, .filter-tab-btn:hover {
    color: #fff; background: #31314d; border-color: #555580;
}

.collection-item, 
.collection-item-img, 
.summary-item, 
.summary-item-img {
    will-change: transform;
    transform: translateZ(0); 
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    image-rendering: -webkit-optimize-contrast; 
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px; width: 100%; max-width: 800px; margin-bottom: 20px;
}
@media (max-width: 500px) { .collection-grid { grid-template-columns: repeat(2, 1fr); } }

.collection-item {
    width: 100%; aspect-ratio: 16 / 9;
    background-color: #12121c; border-radius: 6px;
    overflow: hidden; position: relative; border: 1px solid #232333;
    display: flex; align-items: flex-end; padding: 8px;
    transition: transform 0.2s ease;
}
.collection-item:not(.unlocked) .collection-item-img {
    filter: grayscale(100%) brightness(35%) !important;
}
.collection-item:not(.unlocked) .collection-item-info {
    opacity: 0.45;
}
.collection-item.unlocked { cursor: pointer; }
.collection-item:hover { transform: scale(1.02) translateZ(0); box-shadow: 0 4px 15px rgba(255,255,255,0.08); }

.collection-item.unit-selected {
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6) !important;
}
.unit-selection-check {
    position: absolute; top: 6px; right: 6px;
    min-width: 24px; height: 24px; padding: 0 6px;
    background: #ffd700; color: #0b0d14; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 0.78rem; z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.6);
}

.item-fav-btn {
    position: absolute; top: 6px; left: 6px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    z-index: 15;
    filter: none !important;
    transition: transform 0.2s, background 0.2s, color 0.2s;
}
.item-fav-btn:hover { transform: scale(1.18); }
.item-fav-btn.active {
    color: #ff3366 !important;
    border-color: #ff3366 !important;
    background: rgba(255, 51, 102, 0.25) !important;
    text-shadow: 0 0 8px rgba(255, 51, 102, 0.8);
}

.unit-deployed-badge {
    position: absolute; top: 6px; left: 36px;
    background: rgba(40, 60, 120, 0.9); color: #ffffff;
    font-size: 0.65rem; font-weight: bold;
    padding: 2px 6px; border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3); z-index: 10;
}
.pickup-owned-badge {
    position: absolute; top: 6px; left: 36px;
    background: #27ae60; color: #ffffff;
    font-size: 0.65rem; font-weight: bold;
    padding: 2px 6px; border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); z-index: 10;
}

.collection-item-img { position: absolute; top:0; left:0; width:100%; height:100%; object-fit: cover; z-index: 1; }
.collection-item-info { position: relative; z-index: 3; }
.collection-item-stars { font-size: 0.65rem; color: #ffd700; text-shadow: 1px 1px 2px #000; }
.collection-item-stars.stars-6 { color: #ffffff; text-shadow: 0 0 6px #00ffff, 1px 1px 2px #000; }
.collection-item-name { font-size: 0.8rem; font-weight: 700; color: #fff; text-shadow: 1px 1px 2px #000; }

.lock-icon {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem; color: rgba(255,255,255,0.25); z-index: 2;
}

.collection-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 20px; margin-bottom: 25px; width: 100%; max-width: 800px;
}
.page-nav-btn {
    background: #181825; color: #fff; border: 1px solid #2d2d3f;
    padding: 8px 16px; border-radius: 4px; cursor: pointer;
    font-size: 0.85rem; transition: all 0.2s;
}
.page-nav-btn:hover:not(:disabled) { background: #31314d; }
.page-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-indicator { font-size: 0.95rem; font-weight: bold; color: #ffd700; }
.collection-footer-btns { display: flex; gap: 12px; }

#collection-overlay .gacha-btn, 
#summary-overlay .gacha-btn,
#formation-overlay .gacha-btn,
#title-codex-overlay .gacha-btn {
    padding: 10px 24px !important;
    font-size: 0.9rem !important;
    width: auto !important; height: auto !important;
    min-width: 120px !important; border-radius: 6px !important;
    flex: none !important; box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
}

.summary-new-badge {
    position: absolute; top: 6px; right: 6px;
    background: #ff3b30; color: #ffffff;
    font-size: 0.65rem; font-weight: bold;
    padding: 2px 6px; border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); z-index: 5;
}

/* ==================== [풀스크린 뷰어 & 대사창 & 태그 나열] ==================== */
#skin-viewer-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    height: 100dvh; height: 100svh;
    background-color: #000; z-index: 300; display: none; opacity: 0; transition: opacity 0.3s ease;
}
#skin-viewer-overlay.active { display: block; opacity: 1; }
.viewer-image { background-size: contain; background-repeat: no-repeat; background-position: center; position: relative; }
#skin-viewer-overlay .carousel-arrow { z-index: 310; background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.2); }

.viewer-top-actions {
    position: absolute;
    top: 4cqh; right: 5cqh;
    display: flex;
    align-items: center;
    gap: 1.5cqh;
    z-index: 320;
}

.viewer-story-btn,
.viewer-favorite-btn {
    width: 7cqh; height: 7cqh;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    display: flex; align-items: center; justify-content: center;
    font-size: 3.2cqh;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(6px);
}
.viewer-favorite-btn:hover { transform: scale(1.12); }
.viewer-favorite-btn.active {
    color: #ff3366;
    border-color: #ff3366;
    background: rgba(255, 51, 102, 0.25);
    box-shadow: 0 0 16px rgba(255, 51, 102, 0.7);
}

.viewer-story-btn:hover {
    transform: scale(1.12);
    border-color: #ffd700;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.5);
    background: rgba(35, 30, 15, 0.8);
}
.viewer-story-btn.active {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.25);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.7);
}

/* 하단 비주얼 노벨 대사창 스타일 */
.viewer-story-card {
    position: absolute;
    bottom: 3.5cqh;
    left: 50%;
    transform: translate(-50%, 20px);
    width: 90%;
    max-width: 140cqh;
    min-height: 18cqh;
    background: linear-gradient(180deg, rgba(8, 11, 20, 0.94) 0%, rgba(4, 6, 14, 0.98) 100%);
    border: 1.5px solid rgba(255, 215, 0, 0.45);
    border-radius: 1.6cqh;
    padding: 1.8cqh 2.8cqh 2.2cqh 2.8cqh;
    z-index: 330;
    backdrop-filter: blur(14px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 25px rgba(255, 215, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    gap: 0.8cqh;
    text-align: left;
}
.viewer-story-card.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.story-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 215, 0, 0.25);
    padding-bottom: 0.8cqh;
}

.story-header-left {
    display: flex;
    align-items: center;
    gap: 1.6cqh;
    flex-wrap: wrap;
    flex: 1;
    padding-right: 15px;
}

.story-char-name {
    font-size: clamp(16px, 2.8cqh, 26px);
    font-weight: 900;
    color: #ffd700;
    letter-spacing: 0.12cqh;
    text-shadow: 0 2px 6px rgba(0,0,0,0.9), 0 0 12px rgba(255, 215, 0, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 0.6cqh;
    white-space: nowrap;
}
.story-char-name::before {
    content: "◆";
    font-size: 0.8em;
    color: #00e5ff;
    text-shadow: 0 0 8px #00e5ff;
}

/* 태그 뱃지 가로 나열 */
.story-tags-container {
    display: flex;
    align-items: center;
    gap: 0.8cqh;
    flex-wrap: wrap;
}

.story-tag-badge {
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid rgba(0, 229, 255, 0.45);
    color: #70d6ff;
    padding: 0.2cqh 0.9cqh;
    border-radius: 1cqh;
    font-size: clamp(11px, 1.6cqh, 16px);
    font-weight: 700;
    letter-spacing: 0.05cqh;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.story-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 3.6cqh;
    height: 3.6cqh;
    min-width: 24px;
    min-height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(12px, 1.8cqh, 18px);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.story-close-btn:hover {
    background: #cc2222;
    border-color: #ff5555;
    transform: scale(1.1);
}

.story-card-body {
    font-size: clamp(13px, 2.3cqh, 20px);
    line-height: 1.65;
    color: #f2f4ff;
    word-break: keep-all;
    text-shadow: 0 1px 3px rgba(0,0,0,0.95);
    font-weight: 500;
}

#custom-confirm-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    height: 100dvh; height: 100svh;
    background-color: rgba(0, 0, 0, 0.8); z-index: 400;
    display: none; justify-content: center; align-items: center;
}
#custom-confirm-modal.active { display: flex; }
.confirm-box {
    background-color: #141420; border: 1px solid #3d3d5c;
    border-radius: 8px; padding: 22px; width: 90%; max-width: 300px; text-align: center;
}
.confirm-msg { font-size: 0.95rem; color: #fff; margin-bottom: 20px; line-height: 1.5; }
.confirm-btn-group { display: flex; gap: 10px; justify-content: center; }
.confirm-action-btn { padding: 10px 20px; border-radius: 4px; font-size: 0.9rem; font-weight: bold; cursor: pointer; border: none; }
.confirm-action-btn.danger { background-color: #cc2222; color: #fff; }
.confirm-action-btn.cancel { background-color: #31314d; color: #fff; }

#summary-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(5, 5, 8, 0.98); z-index: 200;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    padding: 30px 20px 70px 20px; overflow-y: scroll; -webkit-overflow-scrolling: touch;
}
#summary-overlay.active { display: flex; }
@media (max-height: 620px) { #summary-overlay { justify-content: flex-start !important; padding-top: 30px !important; } }

.summary-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 18px; }
.summary-grid {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 10px; width: 100%; max-width: 850px; margin-bottom: 25px;
}
@media (max-width: 768px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }

.summary-item {
    aspect-ratio: 16 / 9; background-color: #12121c; border-radius: 6px;
    overflow: hidden; position: relative; border: 1px solid #232333;
    display: flex; align-items: flex-end; padding: 8px; transition: transform 0.2s ease;
}
.summary-item:hover { transform: scale(1.02) translateZ(0); }
.summary-item.item-6 { border: 2px solid #ffffff; box-shadow: 0 0 15px rgba(0, 240, 255, 0.8); }
.summary-item.item-5 { border: 1.5px solid #ffd700; }
.summary-item.item-4 { border: 1.5px solid #d370ff; }
.summary-item.item-3 { border: 1.5px solid #4cb2ff; }

.summary-item-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.summary-item-info { position: relative; z-index: 3; }
.summary-item-stars { font-size: 0.65rem; color: #ffd700; text-shadow: 1px 1px 2px #000; }
.summary-item-stars.stars-6 { color: #ffffff; text-shadow: 0 0 8px #00ffff, 1px 1px 2px #000; }
.summary-item-name { font-size: 0.8rem; font-weight: 700; color: #fff; text-shadow: 1px 1px 2px #000; }

#portrait-warning {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: #0c0c12; z-index: 9999; display: none;
    flex-direction: column; justify-content: center; align-items: center;
    text-align: center; padding: 30px; color: #ffffff;
}
@media (orientation: portrait) { #portrait-warning { display: flex; } }
.phone-icon-wrapper { width: 80px; height: 80px; margin-bottom: 20px; }
.phone-rotate-icon { fill: #ffd700; width: 100%; height: 100%; animation: rotate-phone-anim 2s infinite ease-in-out; }

@keyframes rotate-phone-anim { 0% { transform: rotate(0deg); } 50% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
.warning-title { font-size: 1.4rem; font-weight: 800; color: #ffd700; margin-bottom: 8px; }
.warning-text { font-size: 0.9rem; color: #b0b0cb; line-height: 1.6; }

#game-loading-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: #050508; z-index: 10000; display: flex;
    justify-content: center; align-items: center; transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-content { text-align: center; width: 95%; max-width: 440px; }
.loading-spinner {
    width: 50px; height: 50px; border: 3px solid rgba(255, 215, 0, 0.1);
    border-top: 3px solid #ffd700; border-radius: 50%;
    animation: spin-anim 1s linear infinite; margin: 0 auto 20px auto;
}
@keyframes spin-anim { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-title { font-size: 1.1rem; font-weight: bold; color: #ffffff; margin-bottom: 15px; letter-spacing: 1px; }
.progress-container { width: 100%; height: 6px; background-color: #1a1a2e; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.progress-bar { width: 0%; height: 100%; background: linear-gradient(90deg, #ffd700, #ff8c00); transition: width 0.1s ease; }
.loading-status { font-size: 0.85rem; color: #b0b0cb; }

/* 모바일 가로 모드 (Short Landscape) 반응형 */
@media (max-width: 768px), (max-height: 520px) {
    #reveal-overlay, #summon-cutscene-overlay, #formation-overlay, #skin-viewer-overlay {
        height: 100dvh !important;
        height: 100svh !important;
    }

    .card-info-overlay { 
        bottom: 8cqh !important; 
        left: 6.5cqh !important; 
    }
    .card-stars { font-size: 3.8cqh !important; }
    .card-skin-name { font-size: 6.4cqh !important; }
    .new-label-overlay { font-size: 2.4cqh !important; }

    .tap-to-continue { 
        font-size: 1.8cqh !important; 
        bottom: 5.5cqh !important; 
        right: 6.5cqh !important; 
    }

    .lobby-mileage-box {
        width: 22cqh !important;
        padding: 0.8cqh 1.2cqh !important;
        bottom: 1.2cqh !important;
    }
    .mileage-info-row { font-size: 1.3cqh !important; }
    .mileage-exchange-btn { font-size: 1.3cqh !important; padding: 0.6cqh 1cqh !important; }

    .bottom-menu-wrapper { bottom: 1.2cqh !important; gap: 1cqh !important; }
    .pickup-slot { width: 9cqh !important; height: 9cqh !important; }
    .pickup-label { font-size: 1.5cqh !important; }
    .gacha-btn { padding: 1.4cqh 2cqh !important; font-size: 1.8cqh !important; }
    
    .formation-slots-container { gap: 1cqh !important; }
    .unit-slot { width: 26cqh !important; height: 39cqh !important; }
    .unit-slot-stars { font-size: 1.4cqh !important; }
    .unit-slot-name { font-size: 1.6cqh !important; }

    .preset-nav-bar { padding: 0.2cqh 0.6cqh !important; gap: 0.6cqh !important; }
    .preset-current-indicator { font-size: 1.5cqh !important; min-width: 10cqh !important; }

    .title-codex-box {
        padding: 12px 16px !important;
        gap: 8px !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
    }
    .codex-header h2 { font-size: 1.1rem !important; }
    .codex-item { padding: 8px 12px !important; gap: 4px !important; }
    .codex-item-name { font-size: 0.85rem !important; }
    .codex-item-members { font-size: 0.72rem !important; }
    .codex-deploy-btn, .codex-clue-btn { padding: 3px 8px !important; font-size: 0.7rem !important; }

    #collection-overlay .gacha-btn, 
    #summary-overlay .gacha-btn,
    #formation-overlay .gacha-btn,
    #title-codex-overlay .gacha-btn {
        padding: 8px 16px !important;
        font-size: 0.8rem !important;
        min-width: 90px !important;
    }
    .collection-pagination { margin-bottom: 15px !important; gap: 10px !important; }
    .page-nav-btn { padding: 6px 12px !important; font-size: 0.75rem !important; }
    .collection-footer-btns { gap: 8px !important; }

    /* 모바일 대사창 최적화 */
    .viewer-story-card {
        width: 94% !important;
        bottom: 2cqh !important;
        min-height: auto !important;
        padding: 1.4cqh 2cqh !important;
    }
    .story-char-name { font-size: clamp(14px, 3.2cqh, 22px) !important; }
    .story-card-body { font-size: clamp(12px, 2.5cqh, 18px) !important; line-height: 1.5 !important; }

    .category-checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
        max-height: 140px !important;
    }
}

/* ==================== [6성 글리치 산산조각 분해 연출] ==================== */
/* 잎사귀가 절대 커지지 않고, 디지털 파편으로 산산조각 나며 완전 소멸 */
.leaf-shattered-6 {
    animation: leafDigitalShatter 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    pointer-events: none;
}

@keyframes leafDigitalShatter {
    0% {
        transform: scale(1) translate(0, 0);
        filter: drop-shadow(0 0 20px #00f0ff) drop-shadow(0 0 35px #ffffff);
        opacity: 1;
    }
    /* 1단계: 차원 균열 - 화면 중앙에서 가로 줄무늬로 지직거리며 찢어짐 */
    12% {
        transform: scale(1) translate(-12px, 4px) skewX(20deg);
        clip-path: polygon(0 0, 100% 0, 100% 20%, 0 20%, 0 45%, 100% 45%, 100% 70%, 0 70%, 0 100%, 100% 100%);
        filter: invert(100%) contrast(250%) drop-shadow(0 0 35px #00f0ff);
    }
    24% {
        transform: scale(1) translate(14px, -6px) skewX(-25deg);
        clip-path: polygon(15% 0, 85% 0, 100% 30%, 10% 40%, 90% 60%, 0% 75%, 85% 100%, 0 100%);
        filter: contrast(350%) hue-rotate(180deg) drop-shadow(0 0 45px #ffffff);
    }
    /* 2단계: 다각도 산산조각 파편화 - 불규칙한 날카로운 조각들로 분해 */
    38% {
        transform: scale(0.98) translate(-16px, -8px) rotate(5deg);
        clip-path: polygon(0 15%, 45% 0, 65% 30%, 15% 55%, 85% 40%, 100% 75%, 40% 85%, 15% 100%);
        filter: drop-shadow(0 0 55px #00f0ff) brightness(2.5);
        opacity: 0.9;
    }
    52% {
        transform: scale(0.95) translate(15px, 9px) rotate(-7deg);
        clip-path: polygon(25% 15%, 75% 5%, 95% 40%, 35% 65%, 80% 80%, 10% 95%);
        filter: drop-shadow(0 0 45px #ffffff) contrast(200%);
        opacity: 0.7;
    }
    /* 3단계: 디지털 노이즈 붕괴 - 입자가 잘게 부서지며 급속 증발 */
    70% {
        transform: scale(0.9) translate(-8px, 10px) skewY(15deg);
        clip-path: polygon(30% 20%, 70% 30%, 80% 60%, 40% 70%, 50% 90%);
        filter: blur(3px) drop-shadow(0 0 60px #00f0ff) brightness(3);
        opacity: 0.35;
    }
    85% {
        transform: scale(0.85) translate(5px, -8px);
        clip-path: polygon(40% 35%, 60% 40%, 55% 65%, 35% 60%);
        filter: blur(6px) brightness(4);
        opacity: 0.12;
    }
    /* 4단계: 잔해 없이 100% 완전 소멸 */
    100% {
        transform: scale(0.8) translate(0, 0);
        clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%);
        filter: blur(10px) brightness(5);
        opacity: 0;
        visibility: hidden;
    }
}

/* 잎사귀가 부서질 때 뒤편의 후광이 우주 충격파처럼 밖으로 폭발하며 소멸 */
.halo-shattered {
    animation: haloSupernovaBurst 0.65s cubic-bezier(0.1, 0.9, 0.2, 1) forwards !important;
}

@keyframes haloSupernovaBurst {
    0% { transform: scale(1); opacity: 1; }
    25% { transform: scale(1.4); opacity: 1; filter: blur(25px) brightness(2.2); }
    100% { transform: scale(2.6); opacity: 0; filter: blur(50px); }
}

@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }