@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #0c0d14; /* OLED Dark */
    --panel-bg: #161722;
    --text-color: #f3f3f6;
    --primary-color: #ff4d8d;
    --primary-glow: rgba(255, 77, 141, 0.3);
    --secondary-color: #00f2fe; /* Dynamic Blue */
    --joker-color: #cf6679;
    --border-color: rgba(255, 255, 255, 0.07);
    --nav-height: 64px;
    
    /* 🆕 CineMythos Premium Overhaul Color Tokens */
    --bg-dark-oled: #0c0d14;
    --bg-dark-card: #161722;
    --gradient-star-aura: linear-gradient(135deg, #00f2fe 0%, #ff4d8d 100%);
    --border-color-glow: rgba(255, 77, 141, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', 'Outfit', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
}

/* 게임 메인 래퍼: 이미지 + UI 레이어를 감싸는 컨테이너 */
.game-main {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    background-color: transparent; /* 완전히 투명하게 설정 */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    pointer-events: auto;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

header h1 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin: 0;
}

.controls input {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 5px 10px;
    border-radius: 4px;
}

.controls button {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* Background Layer — PC 기본: 상단 이미지 영역 */
.bg-layer {
    position: relative;
    width: 100%;
    height: 30vh;   /* 이미지 칸 축소 (45→30) */
    z-index: 1;
    overflow: hidden;
    background-color: #000;
    flex-shrink: 0;
}

.bg-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

.bg-overlay {
    display: none;
}

/* Nav Buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 2rem;
    padding: 10px;
    cursor: pointer;
    border-radius: 4px;
    z-index: 10;
}
.nav-btn:hover { background: rgba(0,0,0,0.8); }
#prevImgBtn { left: 10px; }
#nextImgBtn { right: 10px; }

/* UI Layer */
.ui-layer {
    position: relative;
    width: 100%;
    flex: 1;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-color: #0d0d12;
    border-top: 1px solid rgba(187, 134, 252, 0.2);
    overflow: hidden;
    padding-top: 0;
}

/* UI 요소들은 다시 클릭 이벤트를 받도록 설정 */
header, .status-container, .chat-section, .action-section, .modal-overlay, #gallerySection, #wikiSection, #graphSection, #mapSection {
    pointer-events: auto;
}

.status-container {
    position: absolute;
    top: 55px; /* 헤더 바로 아래 */
    right: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    background-color: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #eee;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    padding: 15px;
    width: 360px;
    max-width: calc(100vw - 32px);
    z-index: 100;
    display: none; /* 기본 숨김 */
}

.chat-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: transparent;
    overflow: hidden; /* 네비게이터 고정, 스크롤은 chat-history만 */
}

/* 턴 네비게이터 바 */
.turn-navigator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 6px 12px;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(187, 134, 252, 0.2);
    flex-shrink: 0;
}

.turn-nav-btn {
    background: rgba(187, 134, 252, 0.15);
    border: 1px solid rgba(187, 134, 252, 0.35);
    color: var(--primary-color);
    font-size: 1rem;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}
.turn-nav-btn:hover:not(:disabled) {
    background: rgba(187, 134, 252, 0.35);
}
.turn-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.turn-counter {
    font-size: 0.85rem;
    color: #bbb;
    min-width: 80px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 0.03em;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    padding: 10px;
    line-height: 1.6;
    background-color: transparent;
    color: white;
    font-size: 1.05rem;
    font-weight: 500;
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         0 2px 6px rgba(0,0,0,1);
}

.system-msg {
    color: #ffda6a; /* 텍스트 섀도우와 어울리는 밝은 노란색 */
    font-style: italic;
    font-weight: bold;
}

.action-section {
    padding: 10px;
    background-color: transparent;
    border-top: none;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.choice-btn {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
    transition: background-color 0.2s, border-color 0.2s;
}

.choice-btn:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
}

.choice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.choice-btn.choices-waiting {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
    border-color: rgba(187, 134, 252, 0.35);
    background-color: rgba(0, 0, 0, 0.4);
    animation: choices-pulse 1.5s infinite ease-in-out;
}

@keyframes choices-pulse {
    0% { opacity: 0.5; }
    50% { opacity: 0.8; }
    100% { opacity: 0.5; }
}

.choice-btn.joker {
    border-color: var(--joker-color);
    color: var(--joker-color);
}

.custom-action {
    display: flex;
    gap: 10px;
}

.custom-action input {
    flex: 1;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 10px;
    border-radius: 6px;
}

.custom-action button {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

/* ============================================================
   📜 스크롤뷰 플레이 — 모든 턴 + 선택한 선택지 + 턴별 TTS 버튼
   (해당 턴만 보여주던 기존 방식 → 위/아래 스크롤로 전체 흐름 읽기)
   ============================================================ */

/* 턴 네비게이터(이전/다음 턴) 바는 스크롤뷰에서 사용하지 않음 */
.turn-navigator { display: none !important; }

/* 한 턴의 모든 요소를 묶는 블록 */
.turn-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.turn-block + .turn-block {
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* 플레이어가 선택한 선택지 칩 */
.turn-action-chip {
    align-self: flex-start;
    max-width: 95%;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    background: linear-gradient(135deg, rgba(255, 77, 141, 0.22), rgba(167, 139, 250, 0.18));
    border: 1px solid rgba(255, 77, 141, 0.45);
    border-radius: 14px;
    color: #ffd9e7;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}
.turn-action-chip .tac-icon {
    color: var(--primary-color);
    font-size: 0.72rem;
    flex-shrink: 0;
}

/* 인라인 씬 이미지 (가로 꽉 채움 — 클릭 시 라이트박스) */
.turn-inline-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    transition: filter 0.15s;
}
.turn-inline-image:hover { filter: brightness(1.06); }

/* 턴별 TTS 재생 버튼 (자동재생 X — 눌렀을 때만 재생) */
.turn-tts-btn {
    align-self: flex-start;
    width: 44px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: rgba(20, 20, 30, 0.85);
    border: 1px solid rgba(187, 134, 252, 0.4);
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.turn-tts-btn:hover {
    background: rgba(167, 139, 250, 0.3);
    border-color: var(--secondary-color);
}
.turn-tts-btn:active { transform: scale(0.94); }
.turn-tts-btn.playing {
    background: rgba(255, 77, 141, 0.3);
    border-color: var(--primary-color);
    animation: choices-pulse 1.4s infinite ease-in-out;
}

/* 활성 선택지를 스크롤 내부 맨 아래에 자연스럽게 배치
   (모바일 .choices 의 max-height/overflow 제약을 무력화하여 스크롤 흐름에 포함) */
.chat-history > #choicesContainer {
    margin-top: 12px;
    margin-bottom: 4px;
    max-height: none !important;
    overflow: visible !important;
}

/* 👑 관리자 패널 탭 */
.admin-tab-btn.active {
    background: var(--primary-color) !important;
    color: #000 !important;
    border-color: var(--primary-color) !important;
    font-weight: bold;
}
.admin-tab-pane .form-group { margin-bottom: 14px; }

/* 모달 스타일 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none; /* 기본적으로 숨김 */
}

.modal-content {
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-color);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #aaa;
}

.form-group select, .form-group input {
    width: 100%;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 8px;
    border-radius: 4px;
}

.helper-text {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

.character-setup {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    margin-bottom: 20px;
}

.char-inputs {
    flex: 1;
}

.char-preview {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed #555;
    border-radius: 8px;
    overflow: hidden;
}

.char-preview img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.primary-btn {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.secondary-btn {
    background-color: #444;
    color: #fff;
    border: 1px solid #666;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

/* 갤러리 스타일 — 전체화면 오버레이 */
.gallery-section {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 16, 0.97);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    padding: 0;
}

.gallery-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(187, 134, 252, 0.25);
    background: linear-gradient(180deg, rgba(30,30,45,0.98), rgba(13,13,18,0.98));
    flex-shrink: 0;
}

.gallery-section-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.gallery-section-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.gallery-grid img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* 라이트박스(이미지 크게 보기) 모달 */
#lightboxModal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    display: none; /* 기본 숨김 */
    cursor: zoom-out;
}

#lightboxModal img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* 📖 Wiki / Graph / Gallery — 전체화면 오버레이 */
.wiki-section {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    /* safe area for mobile notch/nav */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(10, 10, 16, 0.97);
    border: none;
    border-radius: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    pointer-events: auto;
    color: #e0e0e0;
    overflow: hidden;
}
.wiki-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    background: linear-gradient(180deg, rgba(30, 30, 40, 0.98), rgba(13, 13, 18, 0.98));
    border-radius: 0;
    flex-shrink: 0;
}
.wiki-header h3 {
    margin: 0;
    color: gold;
    text-shadow: 1px 1px 2px black;
}
.wiki-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.wiki-sidebar {
    width: 250px;
    background: rgba(0, 0, 0, 0.5);
    border-right: 1px solid rgba(255, 215, 0, 0.2);
    overflow-y: auto;
    padding: 15px;
}
.wiki-main {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: rgba(20, 20, 25, 0.8);
    line-height: 1.6;
}
.wiki-link {
    cursor: pointer;
    color: #4da6ff;
    text-decoration: underline;
    transition: color 0.2s;
}
.wiki-link:hover {
    color: #ffcc00;
}
/* 마크다운 테이블 스타일 */
.wiki-main table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}
.wiki-main th, .wiki-main td {
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    text-align: left;
}
.wiki-main th {
    background: rgba(255, 215, 0, 0.1);
    color: gold;
}
.wiki-sidebar a {
    display: block;
    padding: 5px 0;
    color: #aaa;
    text-decoration: none;
    cursor: pointer;
}
.wiki-sidebar a:hover {
    color: gold;
}

/* 아이콘 및 리트라이 버튼 스타일 */
/* 헤더 상태/지도/설정: 아이콘만 표시 + 불투명(둥근) 버튼 */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-btn {
    width: 38px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 22, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    color: white;
    text-shadow: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s, background-color 0.15s, border-color 0.15s;
}
.icon-btn:hover {
    transform: scale(1.08);
    background: rgba(40, 40, 56, 0.95);
    border-color: rgba(187, 134, 252, 0.5);
}

.retry-btn {
    flex: 1;
    background-color: rgba(200, 100, 0, 0.7);
    color: white;
    border: 1px solid rgba(255, 150, 0, 0.5);
    padding: 8px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    text-shadow: 1px 1px 2px black;
    transition: all 0.2s;
}
.retry-btn:hover:not(:disabled) {
    background-color: rgba(255, 120, 0, 0.9);
    border-color: rgba(255, 200, 0, 0.8);
}
.retry-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background-color: rgba(100, 100, 100, 0.5);
    border-color: rgba(150, 150, 150, 0.3);
}

/* 🎙️ TTS Voice Option Cards */
.voice-option-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: #2b2b2b;
    border-radius: 6px;
    border: 1px solid #3d3d3d;
    transition: all 0.2s ease;
    cursor: pointer;
}
.voice-option-card:hover {
    background-color: #333;
    border-color: #555;
}
.voice-option-card label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    color: #fff;
    cursor: pointer;
    flex: 1;
}
.voice-option-card input[type="radio"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}
.voice-option-card.selected {
    border-color: var(--primary-color);
    background-color: rgba(187, 134, 252, 0.1);
}
.voice-play-btn {
    background-color: #444;
    border: 1px solid #555;
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}
.voice-play-btn:hover {
    background-color: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}
.voice-play-btn.playing {
    color: var(--secondary-color);
    border-color: var(--secondary-color);
    background-color: rgba(3, 218, 198, 0.1);
    animation: voice-pulse 1s infinite alternate;
}
@keyframes voice-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* =====================================================
   📱 모바일 레이아웃: 이미지 패널 / 스토리 패널 분리
   ===================================================== */
@media (max-width: 768px) {

    body {
        overflow: hidden;
    }

    #app {
        background-color: #0d0d12;
    }

    /* game-main: 이미지(상단) + UI(하단) 을 세로로 분리 */
    .game-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    /* ─── 이미지 패널 (상단 28%) ─── */
    .bg-layer {
        position: relative;       /* 절대위치 해제 → 일반 흐름으로 */
        width: 100%;
        height: 28vh;              /* 뷰포트 28% (35→28) */
        height: 28dvh;
        flex-shrink: 0;
        z-index: 0;
        background-color: #000;
        overflow: hidden;
    }

    .bg-layer img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center top;
        display: block;
    }

    /* 이미지 하단에 그라디언트 페이드 효과 */
    .bg-layer::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 40%;
        background: linear-gradient(to bottom, transparent, #0d0d12);
        pointer-events: none;
    }

    /* ─── UI 레이어 (하단 나머지) ─── */
    .ui-layer {
        position: relative;       /* 절대위치 해제 */
        top: auto;
        left: auto;
        width: 100%;
        flex: 1;                  /* 나머지 공간 전부 (이미지 줄인 만큼 더 커짐) */
        min-height: 0;
        display: flex;
        flex-direction: column;
        background-color: #0d0d12;
        border-top: 1px solid rgba(187, 134, 252, 0.2);
        overflow: hidden;
        padding-top: 0;
    }

    header h1 {
        font-size: 1rem;
    }

    /* ─── 채팅 영역: 남은 공간을 꽉 채움 ─── */
    .chat-section {
        flex: 1;
        min-height: 0;
        overflow: hidden;         /* 내부 스크롤은 chat-history에서 처리하여 영역 확보 */
        padding: 10px 12px;
        background-color: #0d0d12;
    }

    .chat-history {
        gap: 8px;
        margin-top: auto;
    }

    /* 메시지: 반투명 배경으로 가독성 UP */
    .message {
        font-size: 0.92rem;
        padding: 8px 10px;
        background-color: rgba(255, 255, 255, 0.04);
        border-radius: 8px;
        border-left: 2px solid rgba(187, 134, 252, 0.3);
        color: #e8e8e8;
        text-shadow: none;
        line-height: 1.65;
    }

    .system-msg {
        background-color: rgba(255, 218, 106, 0.08);
        border-left-color: rgba(255, 218, 106, 0.6);
    }

    /* ─── 선택지 / 리트라이 / 입력 영역 ─── */
    .action-section {
        padding: 8px 10px;
        background-color: #0d0d12;
        border-top: 1px solid rgba(255,255,255,0.07);
        flex-shrink: 0;
    }

    .choices {
        gap: 6px;
        margin-bottom: 6px;
        max-height: 18dvh;        /* 선택지 칸 소폭 축소 */
        overflow-y: auto;
    }

    .choice-btn {
        font-size: 0.88rem;
        padding: 8px 10px;
        background-color: rgba(30, 30, 45, 0.95);
        border-color: rgba(187, 134, 252, 0.25);
        backdrop-filter: none;
    }

    .choice-btn.joker {
        border-color: rgba(207, 102, 121, 0.6);
    }

    .retry-btn {
        font-size: 0.82rem;
        padding: 7px 4px;
    }

    .custom-action {
        gap: 8px;
    }

    .custom-action input {
        padding: 8px 10px;
        font-size: 0.88rem;
        background-color: #1a1a2a;
        border-color: rgba(255,255,255,0.15);
        border-radius: 8px;
    }

    .custom-action button {
        padding: 8px 14px;
        font-size: 0.88rem;
        border-radius: 8px;
    }

    /* 이미지 네비게이션 버튼 모바일 조정 */
    .nav-btn {
        font-size: 1.4rem;
        padding: 6px 8px;
        top: 50%;
    }
}

/* --- HUD Tab Navigation & Elements --- */
.hud-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
    padding-bottom: 6px;
    gap: 4px;
}
.hud-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 2px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-align: center;
}
.hud-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}
.hud-tab-btn.active {
    background: rgba(187, 134, 252, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(187, 134, 252, 0.3);
}

.hud-content {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.hud-content::-webkit-scrollbar {
    width: 4px;
}
.hud-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.hud-tab-pane {
    display: none;
}
.hud-tab-pane.active {
    display: block;
}

/* Stats Styling */
.hud-char-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
    margin-bottom: 8px;
}
.hud-char-title {
    font-size: 0.75rem;
    color: #888;
    font-style: italic;
}
.hud-char-class-lvl {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: bold;
}
.hud-bar-group {
    margin-bottom: 8px;
}
.hud-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 2px;
}
.hud-bar-outer, .hud-bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.hud-bar-inner, .hud-bar {
    height: 100%;
    transition: width 0.3s ease;
}
.hud-bar-hp, .hp-bar { background: #ff4d4d; }
.hud-bar-mp, .mp-bar { background: #3399ff; }
.hud-bar-sp, .st-bar { background: #ffcc00; }
.hud-bar-xp, .xp-bar { background: #22c55e; }
.happy-bar { background: linear-gradient(90deg, #ff8aae, #ffd43b); }


.hud-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 10px;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.hud-stat-item {
    display: flex;
    justify-content: space-between;
}
.hud-stat-label { color: #aaa; }
.hud-stat-val { font-weight: bold; color: #fff; }

.hud-equip-section {
    margin-top: 10px;
    font-size: 0.75rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 8px;
}
.hud-equip-title {
    color: var(--secondary-color);
    margin-bottom: 4px;
    font-weight: bold;
}
.hud-equip-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}
.hud-equip-label { color: #888; }
.hud-equip-val { color: #eee; }

/* Inventory Styling */
.hud-item-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hud-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.hud-item-name-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}
.hud-item-qty {
    font-size: 0.75rem;
    color: #aaa;
    background: rgba(0,0,0,0.3);
    padding: 1px 6px;
    border-radius: 10px;
}
.rarity-tag {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: bold;
    text-transform: uppercase;
}
.rarity-common { background: rgba(120, 120, 120, 0.2); color: #ccc; }
.rarity-rare { background: rgba(51, 153, 255, 0.2); color: #3399ff; border: 1px solid rgba(51, 153, 255, 0.4); }
.rarity-epic { background: rgba(187, 134, 252, 0.2); color: var(--primary-color); border: 1px solid rgba(187, 134, 252, 0.4); }
.rarity-legend { background: rgba(255, 204, 0, 0.2); color: #ffcc00; border: 1px solid rgba(255, 204, 0, 0.4); animation: glow 1.5s infinite alternate; }

@keyframes glow {
    from { box-shadow: 0 0 2px rgba(255,204,0,0.2); }
    to { box-shadow: 0 0 6px rgba(255,204,0,0.6); }
}

/* Companion Styling */
.hud-companion-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hud-companion-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px;
}
.hud-comp-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 4px;
}
.hud-comp-mood {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
}
.hud-comp-affinity {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}
.hud-comp-heart {
    color: #ff4d4d;
    font-size: 0.8rem;
}
.hud-comp-bar-outer {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.hud-comp-bar-inner {
    height: 100%;
    background: #ff4d4d;
    transition: width 0.3s ease;
}
.hud-comp-affinity-val {
    font-size: 0.7rem;
    color: #aaa;
    min-width: 24px;
    text-align: right;
}
.hud-comp-thought {
    font-size: 0.7rem;
    color: #aaa;
    font-style: italic;
    margin-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 4px;
}

/* Quest Styling */
.hud-quest-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hud-quest-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.75rem;
}
.hud-quest-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.hud-quest-tag {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
}
.hud-quest-main { background: rgba(3, 218, 198, 0.2); color: var(--secondary-color); }
.hud-quest-side { background: rgba(187, 134, 252, 0.2); color: var(--primary-color); }
.hud-quest-status {
    font-weight: bold;
}
.hud-quest-active { color: var(--secondary-color); }
.hud-quest-completed { color: #22c55e; }
.hud-quest-failed { color: #ff4d4d; }
.hud-quest-desc {
    color: #bbb;
    margin: 4px 0;
}
.hud-quest-rewards {
    font-size: 0.7rem;
    color: #888;
    margin-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 4px;
}

/* ===== Phase 4d: Lore-Anchor 스타일 ===== */
.lore-link {
    color: var(--primary-color, #4facfe);
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: rgba(79, 172, 254, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}
.lore-link:hover {
    color: var(--secondary-color, #03dac6);
    text-decoration-color: var(--secondary-color, #03dac6);
    text-shadow: 0 0 8px rgba(3, 218, 198, 0.5);
}
.lore-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    background: rgba(18, 18, 30, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--primary-color, #4facfe);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(79, 172, 254, 0.3);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.lore-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(79, 172, 254, 0.1);
    border-bottom: 1px solid rgba(79, 172, 254, 0.2);
    color: var(--primary-color, #4facfe);
    font-weight: bold;
}
.lore-popup-content {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(80vh - 50px);
    color: #ccc;
    font-size: 0.9rem;
    line-height: 1.6;
}
.lore-popup-content::-webkit-scrollbar {
    width: 6px;
}
.lore-popup-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.lore-popup-content::-webkit-scrollbar-thumb {
    background: rgba(79, 172, 254, 0.3);
    border-radius: 3px;
}
.hud-env-info {
    color: #aaa;
}

/* ═══ 초상화 생성 프로그레스 바 ═══ */
#portraitProgressWrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#portraitProgressBar {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(187, 134, 252, 0.25);
}

#portraitProgressFill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #bb86fc, #03dac6, #bb86fc);
    background-size: 200% 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
    animation: portraitShimmer 1.8s linear infinite;
}

@keyframes portraitShimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

#portraitProgressLabel {
    font-size: 0.8rem;
    color: #bb86fc;
    text-align: center;
    letter-spacing: 0.03em;
    opacity: 0.9;
}

#btnGeneratePortrait:disabled,
#btnGeneratePortraitI2I:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* 🏷️ 세계관 커스텀 캐릭터 추천 칩/태그 스타일 */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    margin-bottom: 8px;
}

.suggestion-chip {
    font-size: 0.75rem;
    padding: 4px 10px;
    background: rgba(187, 134, 252, 0.08);
    border: 1px solid rgba(187, 134, 252, 0.25);
    color: #dfc8ff;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    letter-spacing: -0.02em;
    backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
}

.suggestion-chip:hover {
    background: rgba(187, 134, 252, 0.2);
    border-color: rgba(187, 134, 252, 0.6);
    color: #ffffff;
    box-shadow: 0 0 8px rgba(187, 134, 252, 0.4);
    transform: translateY(-1px);
}

.suggestion-chip:active {
    transform: translateY(1px);
}

/* 💘 세계관 특화 이미지 카드 선택 UI */
.image-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.image-select-card {
    background: rgba(30, 30, 45, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.image-select-card:hover {
    transform: translateY(-4px);
    border-color: rgba(187, 134, 252, 0.5);
    box-shadow: 0 4px 15px rgba(187, 134, 252, 0.2);
}

.image-select-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px rgba(187, 134, 252, 0.5);
    background: rgba(187, 134, 252, 0.08);
}

.image-select-card-img-wrap {
    width: 100%;
    height: 180px; /* 늘려서 상반신을 더 시원하게 보여줍니다 */
    overflow: hidden;
    position: relative;
    background-color: #000;
}

.image-select-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top; /* 상반신 중심 포커스 */
    transition: transform 0.5s ease;
}

.image-select-card:hover .image-select-card-img-wrap img {
    transform: scale(1.06);
}

.image-select-card-info {
    padding: 8px;
    font-size: 0.75rem;
    color: #eee;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.image-select-card-title {
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-select-card-desc {
    color: #aaa;
    font-size: 0.7rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.image-select-card-check {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--primary-color);
    color: #000;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 2;
}

.image-select-card.selected .image-select-card-check {
    display: flex;
}

/* 🎲 모험 준비 전체화면 모달 스타일 */
#setupModal.modal-overlay {
    background-color: #0b0b12 !important;
    background-image: radial-gradient(circle at 50% 50%, rgba(30, 30, 50, 0.6) 0%, #08080f 100%) !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
}

#setupModal .modal-content {
    width: 100vw !important;
    height: auto !important;
    min-height: 100vh !important;
    max-width: 100vw !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    background: transparent !important;
    padding: 60px 24px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    box-sizing: border-box !important;
    overflow-y: visible !important;
}

#setupModal .modal-content > h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 25px;
    width: 100%;
    max-width: 700px;
    color: var(--primary-color);
}

#setupModal .setup-progress {
    width: 100%;
    max-width: 700px;
    margin-bottom: 35px !important;
    font-size: 1rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

#setupModal #setupStep1Content,
#setupModal #setupStep2Content,
#setupModal #setupStep3Content {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

#setupModal .character-setup {
    width: 100%;
    margin-top: 15px;
}

#setupModal .char-inputs {
    width: 100% !important;
    max-width: 100% !important;
    padding-right: 0 !important;
}

/* 🌌 이미지 더블클릭 전체화면 확대 오버레이 */
.image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 5, 10, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.image-preview-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.image-preview-container {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: previewZoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes previewZoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.image-preview-container img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.1);
    object-fit: contain;
}

.image-preview-title {
    margin-top: 15px;
    font-size: 1.25rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
}

.image-preview-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 3rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
    z-index: 3100;
}

.image-preview-close:hover {
    transform: scale(1.1);
    color: var(--primary-color);
}

/* 🌍 세계관 이미지 카드 그리드 ───────────────────────── */
.world-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
}

.world-card {
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border-color);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}

.world-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 6px 18px rgba(187, 134, 252, 0.25);
}

.world-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color), 0 8px 22px rgba(187, 134, 252, 0.45);
}

.world-card-img-wrap {
    width: 100%;
    aspect-ratio: 4 / 5;
    /* 이미지 로드 실패 시 보이는 폴백 그라데이션 */
    background: linear-gradient(135deg, #2a2240 0%, #1a1626 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.world-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.world-card-label {
    padding: 8px 6px;
    font-size: 0.8rem;
    line-height: 1.25;
    text-align: center;
    color: #e8e8e8;
    background: rgba(0, 0, 0, 0.35);
    word-break: keep-all;
}

.world-card.selected .world-card-label {
    color: var(--primary-color);
    font-weight: 600;
}

/* ════════════════════════════════════════════════════════════
   📱 모바일 홈 셸 (melting 스타일) — 홈 화면 + 하단 탭 네비게이션
   ════════════════════════════════════════════════════════════ */

#homeScreen {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

#homeScreen.visible { display: flex; }

.home-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
}

.home-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.home-logo .logo-dot { color: #fff; }

.home-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
}

.home-tab-pane { display: none; }
.home-tab-pane.active { display: block; }

.home-section-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    padding: 14px 18px 12px;
}

/* ── 세계관 피드 카드 (이미지 + 반투명 설명 오버레이) ── */
.wfeed-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 16px;
}

@media (min-width: 560px) {
    .wfeed-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.wfeed-card {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 18px;
    overflow: hidden;
    border: 1.5px solid rgba(255, 77, 141, 0.55);
    background: linear-gradient(135deg, #262738 0%, #181925 100%);
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.wfeed-card:active { transform: scale(0.965); }
.wfeed-card:hover  { border-color: var(--primary-color); }

.wfeed-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wfeed-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 42px 12px 12px;
    background: linear-gradient(to top, rgba(12, 12, 20, 0.94) 0%, rgba(12, 12, 20, 0.72) 55%, transparent 100%);
}

.wfeed-name {
    font-size: 1.02rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.25;
    margin-bottom: 5px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.wfeed-desc {
    font-size: 0.76rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.78);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wfeed-loading {
    grid-column: 1 / -1;
    text-align: center;
    color: #777;
    padding: 40px 0;
    font-size: 0.9rem;
}

/* ── 대화(이어하기) 빈 상태 ── */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 30px;
    text-align: center;
    gap: 14px;
}

.chat-empty .ce-icon { font-size: 3rem; }
.chat-empty .ce-text { color: #9a9bac; font-size: 0.95rem; line-height: 1.6; }

/* ── 창작 / 마이페이지 공통 메뉴 ── */
.home-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px;
}

.home-menu-btn {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 12px;
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.home-menu-btn:active { transform: scale(0.96); border-color: var(--primary-color); }
.home-menu-btn .hm-icon { font-size: 1.7rem; }

.mypage-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 18px 18px;
}

.mypage-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #b03070);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.mypage-email { font-size: 0.95rem; color: #d8d8e2; word-break: break-all; }

.mypage-saves {
    margin: 6px 16px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.mypage-save-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.mypage-save-row:last-child { border-bottom: none; }
.mypage-save-row .ms-name { flex: 1; color: #e8e8ee; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ms-btn {
    border: none;
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ms-btn.load { background: var(--primary-color); color: #fff; }
.ms-btn.del  { background: #3a2030; color: #ff8aae; }

.mypage-empty { padding: 24px; text-align: center; color: #777; font-size: 0.88rem; }

/* ── 하단 탭 네비게이션 ── */
#bottomNav {
    display: none;
    flex-shrink: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #191a24;
    border-top: 1px solid var(--border-color);
    z-index: 500;
}

#bottomNav.visible { display: flex; }

.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: #80818f;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bnav-item .bn-icon { font-size: 1.3rem; line-height: 1; }

.bnav-item.active { color: var(--primary-color); }

.bnav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--primary-color);
}

/* ── 간단 토스트 ── */
#homeToast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(8px);
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid var(--primary-color);
    color: #fff;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 0.85rem;
    z-index: 11000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

#homeToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ════════════════════════════════════════════════════════════
   📱 모바일 홈 셸 추가 컴포넌트 스타일 (melting 디자인 매칭)
   ════════════════════════════════════════════════════════════ */

.logo-heart {
    color: var(--primary-color);
    margin-left: 3px;
    font-size: 1.15rem;
    filter: drop-shadow(0 0 5px var(--primary-glow));
    vertical-align: middle;
}

.promo-capsule-btn {
    background: linear-gradient(135deg, #ff4d8d 0%, #b03070 100%);
    border: none;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    color: #777;
    padding: 40px 0;
    font-size: 0.9rem;
}

/* ── 대화(이어하기) 빈 상태 ── */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 30px;
    text-align: center;
    gap: 14px;
}

.chat-empty .ce-icon { font-size: 3rem; }
.chat-empty .ce-text { color: #9a9bac; font-size: 0.95rem; line-height: 1.6; }

/* ── 창작 / 마이페이지 공통 메뉴 ── */
.home-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px;
}

.home-menu-btn {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 12px;
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.home-menu-btn:active { transform: scale(0.96); border-color: var(--primary-color); }
.home-menu-btn .hm-icon { font-size: 1.7rem; }

.mypage-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 18px 18px;
}

.mypage-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #b03070);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.mypage-email { font-size: 0.95rem; color: #d8d8e2; word-break: break-all; }

.mypage-saves {
    margin: 6px 16px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.mypage-save-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.mypage-save-row:last-child { border-bottom: none; }
.mypage-save-row .ms-name { flex: 1; color: #e8e8ee; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ms-btn {
    border: none;
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ms-btn.load { background: var(--primary-color); color: #fff; }
.ms-btn.del  { background: #3a2030; color: #ff8aae; }

.mypage-empty { padding: 24px; text-align: center; color: #777; font-size: 0.88rem; }

/* ── 하단 탭 네비게이션 ── */
#bottomNav {
    display: none;
    flex-shrink: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #191a24;
    border-top: 1px solid var(--border-color);
    z-index: 500;
}

#bottomNav.visible { display: flex; }

.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: #80818f;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bnav-item .bn-icon { font-size: 1.3rem; line-height: 1; }

.bnav-item.active { color: var(--primary-color); }

.bnav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--primary-color);
}

/* ── 간단 토스트 ── */
#homeToast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(8px);
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid var(--primary-color);
    color: #fff;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 0.85rem;
    z-index: 11000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

#homeToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ════════════════════════════════════════════════════════════
   📱 모바일 홈 셸 추가 컴포넌트 스타일 (melting 디자인 매칭)
   ════════════════════════════════════════════════════════════ */

.logo-heart {
    color: var(--primary-color);
    margin-left: 3px;
    font-size: 1.15rem;
    filter: drop-shadow(0 0 5px var(--primary-glow));
    vertical-align: middle;
}

.promo-capsule-btn {
    background: linear-gradient(135deg, #ff4d8d 0%, #b03070 100%);
    border: none;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 77, 141, 0.2);
    transition: transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}
.promo-capsule-btn:active {
    transform: scale(0.95);
}

.home-sub-tabs {
    display: flex;
    gap: 16px;
    padding: 4px 18px 10px;
    border-bottom: 1px solid var(--border-color);
}
.sub-tab-btn {
    background: none;
    border: none;
    color: #727383;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    padding-bottom: 4px;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.sub-tab-btn.active {
    color: #fff;
}
.sub-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--primary-glow);
}

.home-promo-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 16px;
    padding: 10px 14px;
    background: rgba(255, 77, 141, 0.08);
    border: 1px solid rgba(255, 77, 141, 0.15);
    border-radius: 12px;
    font-size: 0.8rem;
}
.promo-content {
    display: flex;
    align-items: center;
    gap: 6px;
}
.promo-gift-icon {
    font-size: 1.05rem;
}
.promo-text {
    color: #ff9eba;
    font-weight: 600;
}
.promo-countdown {
    background: #ff4d8d;
    color: #fff;
    font-weight: 800;
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(255, 77, 141, 0.25);
}

/* wfeed 카드 스타일 보정 */
.wfeed-card {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.wfeed-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-glow);
}
.wfeed-overlay {
    background: linear-gradient(to top, rgba(12, 12, 20, 0.95) 0%, rgba(12, 12, 20, 0.65) 60%, transparent 100%) !important;
}
.wfeed-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    color: #fff;
}
.wfeed-desc {
    color: #b6b7c4 !important;
    font-size: 0.74rem;
    line-height: 1.4;
}

/* 피처드 캐릭터 가로 스크롤 */
.char-scroll-container {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 0 16px 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    user-select: none;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
}
.char-scroll-container.active-dragging {
    cursor: grabbing;
}
.char-scroll-container::-webkit-scrollbar {
    display: none;
}
.char-card {
    flex: 0 0 200px;
    width: 200px;
    cursor: pointer;
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    scroll-snap-align: start;
}
.char-card:active {
    transform: scale(0.96);
}
.char-card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #181924;
    margin-bottom: 6px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}
.char-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.char-card-overlay {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #ff4d8d;
}
.char-card-stats {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0,0,0,0.6);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 0.6rem;
    color: #fff;
}
.char-card-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.char-card-desc {
    font-size: 0.76rem;
    color: #8c8d9e;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 하단 탭 바 글래스모피즘 보완 */
#bottomNav {
    background: rgba(25, 26, 36, 0.82) !important;
    backdrop-filter: blur(14px) !important;
    border-top: 1.5px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3) !important;
}

/* =====================================================================
   👑 관리자 패널 신규 고도화 기능 CSS (2FA, 핑, 차트, 에디터 툴 카드)
   ===================================================================== */

/* 📡 실시간 헬스 LED 핑 */
.health-status-container {
    display: flex;
    gap: 15px;
    margin: 12px 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.health-node {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}
.led-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #888;
    display: inline-block;
    transition: background-color 0.3s, box-shadow 0.3s;
}
.led-green {
    background-color: #00e676;
    box-shadow: 0 0 8px #00e676;
}
.led-red {
    background-color: #ff1744;
    box-shadow: 0 0 8px #ff1744;
}

/* 🔐 2FA 스위치 토글 */
.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    margin-bottom: 8px;
}
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #3a3a4a;
    transition: .3s;
    border-radius: 22px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--primary-color);
}
input:checked + .slider:before {
    transform: translateX(22px);
}

/* 📊 분석 SVG 차트 */
.analytics-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 15px;
}
.chart-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 12px;
}
.chart-card-title {
    font-size: 0.9rem;
    color: #bbb;
    margin-bottom: 8px;
    font-weight: bold;
    border-left: 3px solid var(--primary-color);
    padding-left: 6px;
}

/* 📝 세계관/NPC 생성기 툴 카드 패턴 */
.tool-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.tool-card {
    background: linear-gradient(135deg, rgba(187, 134, 252, 0.05) 0%, rgba(3, 218, 198, 0.03) 100%);
    border: 1px dashed rgba(187, 134, 252, 0.3);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.tool-card:hover {
    border-color: var(--primary-color);
    background: rgba(187, 134, 252, 0.1);
    transform: translateY(-2px);
}
.tool-card-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
}
.tool-card-text {
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
}

/* 🛠️ 인앱 에디터 모달 오버레이 */
.editor-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}
.editor-modal-content {
    background: #12131a;
    border: 1px solid rgba(187, 134, 252, 0.2);
    border-radius: 12px;
    width: 100%;
    max-width: 650px;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}
.editor-modal-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.editor-modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.15rem;
}
.editor-modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}
.editor-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.editor-full-width {
    grid-column: span 2;
}
.editor-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.editor-form-group label {
    font-size: 0.82rem;
    color: #aaa;
    font-weight: bold;
}
.editor-form-group input, .editor-form-group select, .editor-form-group textarea {
    padding: 8px 10px;
    background: #1e1f29;
    border: 1px solid #3d3e4d;
    border-radius: 6px;
    color: white;
    font-size: 0.88rem;
    width: 100%;
    box-sizing: border-box;
}
.editor-form-group textarea {
    resize: vertical;
}
.editor-form-group input:focus, .editor-form-group select:focus, .editor-form-group textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}
.editor-modal-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #0d0e14;
}

/* 🚨 모더레이션 실시간 경고 토스트 */
#adminToastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: 100%;
}
.admin-toast {
    background: rgba(18, 19, 26, 0.95);
    border: 1px solid rgba(255, 23, 68, 0.4);
    border-left: 5px solid #ff1744;
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    animation: toast-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
    transition: transform 0.2s, opacity 0.2s;
}
.admin-toast:hover {
    transform: translateY(-2px);
    background: rgba(26, 27, 36, 0.98);
}
@keyframes toast-in {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
.admin-toast-header {
    font-weight: bold;
    color: #ff1744;
    font-size: 0.88rem;
    display: flex;
    justify-content: space-between;
}
.admin-toast-body {
    font-size: 0.82rem;
    color: #e0e0e0;
    line-height: 1.4;
    word-break: break-all;
}

/* 💬 OOC 지문 및 콘텐츠 안전 위반 메시지 스타일링 */
.ooc-highlight {
    color: rgba(224, 143, 214, 0.7) !important;
    font-style: italic;
    background: rgba(184, 34, 166, 0.05);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.88em;
    display: inline-block;
    margin: 2px 0;
    border-left: 2px solid rgba(184, 34, 166, 0.4);
    word-break: break-all;
}

.safety-block-msg {
    background: rgba(239, 68, 68, 0.08) !important;
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
    border-left: 4px solid #ef4444 !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
    color: #f87171 !important;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
    margin: 8px 0;
}

/* 📱 모바일 SNS 피드 및 일기장 프레임 연출 */
.sns-feed-card {
    background: #141522;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    margin: 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.sns-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sns-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 1.5px solid var(--primary-color);
    background-color: #222;
}

.sns-user-info {
    display: flex;
    flex-direction: column;
}

.sns-username {
    font-weight: 700;
    font-size: 0.9rem;
    color: #ffffff;
}

.sns-location {
    font-size: 0.75rem;
    color: #a0a0a0;
    margin-top: 2px;
}

.sns-image-container {
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    background-color: #000;
}

.sns-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sns-actions {
    display: flex;
    gap: 16px;
    padding: 12px 16px 8px;
    font-size: 1.25rem;
    color: #ffffff;
}

.sns-action-icon {
    cursor: pointer;
    transition: transform 0.2s;
}

.sns-action-icon:hover {
    transform: scale(1.1);
    color: var(--primary-color);
}

.sns-body {
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #e0e0e0;
}

.sns-caption-username {
    font-weight: 700;
    margin-right: 8px;
    color: #ffffff;
}

.sns-comments {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.1);
}

.sns-comment-item {
    font-size: 0.85rem;
    margin-bottom: 6px;
    line-height: 1.4;
    color: #ccc;
}

.sns-comment-user {
    font-weight: 700;
    margin-right: 6px;
    color: #fff;
}


/* 📔 아날로그 일기장 프레임 연출 */
.diary-frame {
    background: #fdfaf2; /* 클래식 미색 아날로그 종이 톤 */
    color: #2b2b2b;
    border: 2px solid #d4c5b3;
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15), inset 0 0 40px rgba(212, 197, 179, 0.2);
    font-family: "Nanum Myeongjo", "Georgia", serif;
    position: relative;
    overflow: hidden;
}

.diary-frame::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 15px;
    width: 2px;
    background: rgba(220, 100, 100, 0.2); /* 일기장 바인딩 빨간줄 */
}

.diary-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #5a4b3b;
    padding-bottom: 8px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a4b3b;
}

.diary-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #1a1a1a;
    border-bottom: 1px dashed #d4c5b3;
    padding-bottom: 8px;
}

.diary-content {
    font-size: 0.95rem;
    line-height: 1.8;
    letter-spacing: 0.03em;
    word-break: break-all;
}

.diary-inner-thoughts {
    margin-top: 20px;
    padding: 12px 16px;
    background: rgba(212, 197, 179, 0.15);
    border-left: 3px solid #8c7b6c;
    border-radius: 4px;
    font-style: italic;
    font-size: 0.9rem;
    color: #4a3e3d;
}

/* ─── 💬 그룹 대화방 커스텀 스타일 ─── */
.group-msg {
    margin: 12px 0 !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    transition: all 0.3s ease;
}

.speaker-label {
    font-size: 0.82rem;
    font-weight: bold;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 진남주별 전용 테두리 및 배경 엠보싱 효과 */
.alexandre-border {
    border-left: 4px solid #d4af37 !important;
    background: rgba(212, 175, 55, 0.06) !important;
}
.alexandre-text {
    color: #ffdf7a;
}

.lucian-border {
    border-left: 4px solid #4a90e2 !important;
    background: rgba(74, 144, 226, 0.06) !important;
}
.lucian-text {
    color: #8cc3ff;
}

.kain-border {
    border-left: 4px solid #a855f7 !important;
    background: rgba(168, 85, 247, 0.06) !important;
}
.kain-text {
    color: #d8b4fe;
}

.calix-border {
    border-left: 4px solid #ef4444 !important;
    background: rgba(239, 68, 68, 0.06) !important;
}
.calix-text {
    color: #fca5a5;
}

/* 상단 다자간 참여 배지 리스트 */
.speaker-badge-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    overflow-x: auto;
}

.speaker-badge {
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.speaker-badge.active-talker {
    background: rgba(187, 134, 252, 0.15);
    border-color: rgba(187, 134, 252, 0.6);
    color: #fff;
    box-shadow: 0 0 8px rgba(187, 134, 252, 0.3);
}

/* ─── RisuAI 방식 부분 재생성 / 여기서 이어쓰기 플로팅 툴팁 ─── */
.partial-edit-tooltip {
    display: flex;
    gap: 8px;
    background: rgba(20, 21, 30, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(187, 134, 252, 0.35);
    border-radius: 12px;
    padding: 6px 8px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    animation: tooltip-fade-in 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pe-btn {
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.pe-btn:hover {
    background: rgba(187, 134, 252, 0.15);
    transform: scale(1.03);
}

.pe-btn:active {
    transform: scale(0.97);
}

.pe-btn-icon {
    font-size: 0.95rem;
}

.pe-btn-text {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.2px;
}

/* 👥 P2P Coop UI Styles */
#coopModal .modal-content {
    background-color: #14151e !important;
    border: 1px solid rgba(0, 242, 254, 0.25) !important;
    box-shadow: 0 10px 30px rgba(0, 242, 254, 0.15) !important;
}

#coopModal h2 {
    color: #00f2fe;
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.coop-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    margin-left: 5px;
}

.coop-badge.host {
    background-color: rgba(79, 172, 254, 0.2);
    color: #4facfe;
    border: 1px solid #4facfe;
}

.coop-badge.guest {
    background-color: rgba(0, 242, 254, 0.2);
    color: #00f2fe;
    border: 1px solid #00f2fe;
}

/* ────────────────────────────────────────────────────────
   CineMythos Premium Frontend Overhaul Styles
   ──────────────────────────────────────────────────────── */

/* tab pane transitions & settings */
.home-tab-pane {
    display: none;
    animation: fade-in-tab 0.35s ease-out;
}
.home-tab-pane.active {
    display: block;
}

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

/* 1. 홈 탭 (#homeTabWorlds) */
.home-promo-banner.guide-banner {
    position: relative;
    border-radius: 16px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.15) 0%, rgba(255, 77, 141, 0.15) 100%);
    border: 1px solid rgba(255, 77, 141, 0.2);
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.promo-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.promo-text-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}
.highlight-blue {
    color: #00f2fe;
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}
.promo-text-sub {
    font-size: 0.85rem;
    color: #b2b5cc;
}

.home-section-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
}

/* 3열 추천 세계관 피드 */
.wfeed-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 600px) {
    .wfeed-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
.wfeed-card {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    background: #161722;
    border: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.wfeed-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.wfeed-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 77, 141, 0.4);
    box-shadow: 0 12px 24px rgba(255, 77, 141, 0.15);
}
.wfeed-card:hover img {
    transform: scale(1.06);
}
.wfeed-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px;
    background: linear-gradient(to top, rgba(12, 13, 20, 0.95) 40%, rgba(12, 13, 20, 0));
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-sizing: border-box;
}
.wfeed-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wfeed-desc {
    font-size: 0.75rem;
    color: #b2b5cc;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}
.char-card-overlay {
    position: absolute;
    padding: 2px 6px;
    background: rgba(255, 77, 141, 0.85);
    color: #fff;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 4px;
    z-index: 2;
}

/* AI 모험 퀵스타트 플로팅 버튼 */
.floating-setup-btn {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-star-aura);
    color: #fff;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 77, 141, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    animation: floating-bounce 3s infinite ease-in-out;
}
.floating-setup-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 8px 24px rgba(255, 77, 141, 0.6);
}
@keyframes floating-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* 2. 내 플레이 탭 (#homeTabMyPlay) */
.myplay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}
.myplay-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}
.myplay-edit-btn {
    background: none;
    border: none;
    color: #ff4d8d;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
}
.myplay-favorites-btn {
    display: flex;
    align-items: center;
    padding: 16px;
    background: rgba(255, 77, 141, 0.05);
    border: 1px solid rgba(255, 77, 141, 0.1);
    border-radius: 14px;
    margin: 0 16px 20px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.myplay-favorites-btn:hover {
    background: rgba(255, 77, 141, 0.09);
    border-color: rgba(255, 77, 141, 0.2);
}
.fav-heart {
    font-size: 1.1rem;
    margin-right: 8px;
}
.fav-text {
    flex: 1;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}
.fav-arrow {
    color: #8a8c9e;
}
.myplay-list-container {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.myplay-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: #161722;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    transition: border-color 0.2s ease;
}
.myplay-card:hover {
    border-color: rgba(255, 77, 141, 0.2);
}
.myplay-card-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.myplay-char-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    background: #000;
}
.myplay-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.myplay-world-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}
.myplay-char-meta {
    font-size: 0.75rem;
    color: #8a8c9e;
}
.myplay-status {
    font-size: 0.75rem;
    color: #ff4d8d;
    font-weight: 700;
}
.myplay-resume-btn {
    padding: 8px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00f2fe, #ff4d8d);
    color: #fff;
    border: none;
    font-weight: bold;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 77, 141, 0.2);
}

/* 3. 채팅 탭 (#homeTabChat) */
.chat-tab-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.chat-tab-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}
.beta-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: rgba(0, 242, 254, 0.15);
    color: #00f2fe;
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 8px;
    font-weight: bold;
    text-transform: uppercase;
}
.chat-character-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chat-character-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #161722;
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 20px;
    transition: all 0.2s ease;
}
.chat-character-card:hover {
    border-color: rgba(0, 242, 254, 0.2);
    box-shadow: 0 8px 24px rgba(0, 242, 254, 0.05);
}
.cc-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.cc-avatar-wrap img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(0, 242, 254, 0.2);
}
.cc-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00f2fe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.cc-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.cc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.cc-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
}
.cc-rating {
    font-size: 0.8rem;
    color: #ffb800;
}
.cc-desc {
    font-size: 0.85rem;
    color: #b2b5cc;
    font-style: italic;
    margin-bottom: 12px;
}
.cc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cc-world-tag {
    font-size: 0.7rem;
    color: #8a8c9e;
    max-width: 65%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cc-chat-btn {
    padding: 6px 14px;
    border-radius: 20px;
    background: linear-gradient(135deg, #00f2fe, #ff4d8d);
    color: #fff;
    border: none;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 242, 254, 0.15);
}

/* 4. MY 탭 (#homeTabMyPage) */
.mypage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}
.mypage-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}
.mypage-header-actions {
    display: flex;
    align-items: center;
}
.star-points-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 20px;
    color: #00f2fe;
    font-weight: bold;
    font-size: 0.85rem;
}
.mypage-profile-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin: 0 16px 20px 16px;
    background: #161722;
    border-radius: 20px;
}
.mypage-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #8a8c9e;
}
.mp-profile-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mypage-email {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
}
.mp-stats-row {
    display: flex;
    gap: 16px;
}
.mp-stat-item {
    font-size: 0.8rem;
    color: #b2b5cc;
}
.mp-stat-item strong {
    color: #fff;
}
.mypage-actions-row {
    display: flex;
    gap: 10px;
    padding: 0 16px;
    margin-bottom: 24px;
}
.mp-action-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
}
.mp-action-btn.secondary-btn {
    background: rgba(255,255,255,0.05);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
}
.mp-action-btn.primary-btn {
    background: linear-gradient(135deg, #00f2fe, #ff4d8d);
    color: #fff;
}
.mypage-sub-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    padding: 0 16px;
    margin-bottom: 16px;
}
.mp-sub-tab {
    padding: 12px 16px;
    background: none;
    border: none;
    color: #8a8c9e;
    font-weight: 700;
    cursor: pointer;
    position: relative;
}
.mp-sub-tab.active {
    color: #ff4d8d;
}
.mp-sub-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: #ff4d8d;
}
.mypage-filters {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 20px;
    overflow-x: auto;
}
.filter-pill {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.03);
    color: #8a8c9e;
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.filter-pill.active {
    background: rgba(255, 77, 141, 0.15);
    color: #ff4d8d;
    border-color: rgba(255, 77, 141, 0.3);
}

/* 5. 세계관 상세 정보 모달 (#worldDetailModal) */
.world-detail-content {
    animation: modal-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-slide-up {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close-top-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}
.modal-close-top-btn:hover {
    background: rgba(255, 77, 141, 0.2);
    color: #ff4d8d;
    border-color: rgba(255, 77, 141, 0.4);
}

.detail-social-badges .social-badge {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: #e0e0e0;
    font-weight: bold;
    border: 1px solid rgba(255,255,255,0.08);
}
.detail-tag {
    font-size: 0.75rem;
    color: #00f2fe;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.2);
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: bold;
}

/* 등장 캐릭터 원형 휠 캐러셀 */
.char-circle-scroll-container::-webkit-scrollbar {
    height: 4px;
}
.char-circle-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}
.detail-char-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 60px;
    flex-shrink: 0;
    cursor: pointer;
}
.detail-char-circle img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 77, 141, 0.3);
    transition: all 0.2s ease;
}
.detail-char-circle:hover img {
    transform: scale(1.08);
    border-color: #ff4d8d;
    box-shadow: 0 0 10px rgba(255, 77, 141, 0.4);
}
.detail-char-name {
    font-size: 0.7rem;
    color: #fff;
    font-weight: bold;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 이어하기 비활성화 상태 스타일 */
.primary-btn.disabled {
    background: #252636 !important;
    color: #555770 !important;
    border: 1px solid rgba(255,255,255,0.02) !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.cc-delete-btn {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(107, 34, 34, 0.45);
    color: #ff8aae;
    border: 1px solid rgba(255, 77, 141, 0.2);
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}
.cc-delete-btn:hover {
    background: rgba(255, 77, 141, 0.25) !important;
    border-color: #ff4d8d !important;
    transform: scale(1.03);
}
.cc-delete-btn:active {
    transform: scale(0.97);
}
