@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

/* --- 🎨 초고퀄리티 테마 4종 --- */
body.theme-glass { 
    --bg-page: #f8fafc; 
    --bg-img: radial-gradient(at 0% 0%, #e0e7ff 0px, transparent 50%), radial-gradient(at 100% 100%, #fae8ff 0px, transparent 50%);
    --bg-surface: rgba(255, 255, 255, 0.7); 
    --bg-board: rgba(255, 255, 255, 0.6);
    --text-main: #0f172a; --text-muted: #64748b; 
    --border: rgba(15, 23, 42, 0.15); --border-board: rgba(255, 255, 255, 0.9);
    --accent: #3b82f6; --accent-hover: #2563eb; --ideal-color: #f59e0b;
    --board-shadow: 0 20px 40px rgba(0,0,0,0.1), inset 0 0 0 4px rgba(255,255,255,0.6);
}
body.theme-cyber { 
    --bg-page: #0f172a; 
    --bg-img: radial-gradient(at 50% 100%, #1e1b4b 0px, transparent 70%), radial-gradient(at 100% 0%, #064e3b 0px, transparent 50%);
    --bg-surface: rgba(15, 23, 42, 0.8); 
    --bg-board: rgba(2, 6, 23, 0.9);
    --text-main: #f8fafc; --text-muted: #94a3b8; 
    --border: rgba(167, 243, 208, 0.3); --border-board: #10b981;
    --accent: #10b981; --accent-hover: #059669; --ideal-color: #f43f5e;
    --board-shadow: 0 0 30px rgba(16, 185, 129, 0.2), inset 0 0 0 2px #10b981;
}
body.theme-arcade { 
    --bg-page: #1e1b4b; 
    --bg-img: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 30px 30px; 
    --bg-surface: rgba(30, 27, 75, 0.9); 
    --bg-board: rgba(2, 6, 23, 0.9);
    --text-main: #e0e7ff; --text-muted: #818cf8; 
    --border: rgba(99, 102, 241, 0.4); --border-board: #6366f1;
    --accent: #8b5cf6; --accent-hover: #7c3aed; --ideal-color: #fcd34d;
    --board-shadow: 0 0 35px rgba(99, 102, 241, 0.3), inset 0 0 0 3px #6366f1;
}
body.theme-synth { 
    --bg-page: #2e1065; 
    --bg-img: linear-gradient(180deg, #2e1065 0%, #701a75 50%, #db2777 100%);
    --bg-surface: rgba(0, 0, 0, 0.4); 
    --bg-board: rgba(0, 0, 0, 0.5);
    --text-main: #fdf2f8; --text-muted: #fbcfe8; 
    --border: rgba(244, 114, 182, 0.3); --border-board: #f472b6;
    --accent: #ec4899; --accent-hover: #db2777; --ideal-color: #38bdf8;
    --board-shadow: 0 0 40px rgba(236, 72, 153, 0.4), inset 0 0 0 3px #f472b6;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body { font-family: 'Pretendard', sans-serif; background-color: var(--bg-page); background-image: var(--bg-img); background-attachment: fixed; color: var(--text-main); overflow: hidden; transition: 0.4s ease; }
.hidden { display: none !important; }
@media (max-width: 600px) { .pc-only { display: none; } }

select, option, button, input { font-family: 'Pretendard', sans-serif !important; }
body.theme-glass .logo-for-dark { display: none; }
body.theme-cyber .logo-for-light, body.theme-arcade .logo-for-light, body.theme-synth .logo-for-light { display: none; }

.global-dropzone { position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; background: rgba(59, 130, 246, 0.85); z-index: 9999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.drop-message { font-size: 2rem; font-weight: 800; color: white; border: 4px dashed white; padding: 40px; border-radius: 24px; }

/* 💡 화면 중앙 정렬을 해제하고 상단으로 끌어올림 (애드센스 공간 확보 및 시각적 안정감) */
.screen-center { 
    display: flex; align-items: flex-start; justify-content: center; 
    height: 100dvh; padding: 12vh 20px 20px 20px; 
    overflow-y: auto; 
}

/* 🌟 업로드 화면 (구도 완벽 통일) */
.setup-container { 
    text-align: center; width: 100%; max-width: 480px; margin: 0 auto; 
}

.setup-logo-link { 
    display: inline-block; margin-bottom: 16px; transition: transform 0.2s; 
}
.setup-logo-link:hover { transform: scale(1.02); }

.setup-logo { 
    height: 44px; width: auto; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05)); 
}

@media (max-width: 768px) {
    .screen-center { padding-top: 10vh; }
    .setup-logo { height: 36px; }
    .setup-logo-link { margin-bottom: 12px; }
}

.game-title { 
    font-size: 2.5rem; font-weight: 900; margin-bottom: 8px; 
    letter-spacing: -0.02em; display: flex; align-items: center; justify-content: center; gap: 10px;
    background: linear-gradient(135deg, var(--text-main), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}
.title-icon { width: 36px; height: 36px; color: var(--accent); }

.game-desc { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 30px; font-weight: 600; letter-spacing: -0.01em;}

.adsense-slot { width: 100%; min-height: 0; display: flex; justify-content: center; align-items: center; }
.setup-adsense { margin-top: 15px; min-height: 50px; } 
.result-adsense { margin-bottom: 15px; min-height: 50px; }

.upload-box { border: 2px dashed var(--border); border-radius: 24px; padding: 40px 20px; background: var(--bg-surface); cursor: pointer; transition: 0.3s; backdrop-filter: blur(10px); }
.upload-box:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 15px 30px rgba(0,0,0,0.1); }
.upload-icon { width: 48px; height: 48px; color: var(--accent); margin-bottom: 15px; }

/* 💡 16:9 반응형 썸네일 CSS */
.sample-section { margin-top: 24px; animation: fadeIn 0.5s ease-out; }
.sample-title { font-size: 0.9rem; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; }
.sample-grid { display: flex; justify-content: center; gap: 8px; width: 100%; }
.sample-img { flex: 1; max-width: 110px; aspect-ratio: 16 / 9; border-radius: 8px; object-fit: cover; cursor: pointer; border: 2px solid transparent; transition: 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.sample-img:hover { transform: translateY(-3px) scale(1.05); border-color: var(--accent); box-shadow: 0 8px 15px rgba(0,0,0,0.2); z-index: 2; }

.tip-box { margin-top: 24px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; font-weight: 600; background: var(--bg-surface); padding: 16px; border-radius: 12px; border: 1px solid var(--border);}
.prep-link-wrapper { margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.link-badge { display: inline-flex; align-items: center; gap: 4px; background: var(--accent); color: white; padding: 4px 12px; border-radius: 20px; font-weight: 700; text-decoration: none; transition: 0.2s; font-size: 0.8rem; box-shadow: 0 4px 10px rgba(0,0,0,0.1);}
.link-badge:hover { background: var(--text-main); transform: translateY(-1px); }

.settings-box { margin-top: 24px; background: var(--bg-surface); padding: 24px; border-radius: 20px; border: 1px solid var(--border); backdrop-filter: blur(10px); text-align: left; animation: fadeIn 0.4s ease-out;}
.setting-group { margin-bottom: 20px; }
.setting-label { display: block; font-weight: 800; font-size: 0.95rem; margin-bottom: 8px; color: var(--text-main);}
.modern-select { width: 100%; padding: 14px; border-radius: 12px; background: var(--bg-page); color: var(--text-main); border: 2px solid var(--border); font-size: 1rem; font-weight: 800; outline: none; cursor: pointer; transition: 0.2s;}
.modern-select:focus { border-color: var(--accent); }

.btn-primary { width: 100%; background: var(--text-main); color: var(--bg-page); border: none; padding: 16px; border-radius: 14px; font-weight: 900; font-size: 1.1rem; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.btn-primary:hover { background: var(--accent); color: #fff; transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.btn-secondary { width: 100%; background: #10B981; color: white; border: none; padding: 16px; border-radius: 14px; font-weight: 800; font-size: 1.1rem; cursor: pointer; transition: 0.2s; }
.btn-secondary:hover { background: #059669; }
.btn-outline { width: 100%; background: transparent; color: var(--text-main); border: 2px solid var(--border); padding: 16px; border-radius: 14px; font-weight: 800; font-size: 1rem; cursor: pointer; transition: 0.2s; }
.btn-outline:hover { background: var(--border); }

/* 🌟 헤더 */
.game-header { position: fixed; top: 0; left: 0; width: 100%; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; background: var(--bg-surface); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); z-index: 200; }
.header-left { display: flex; align-items: center; gap: 20px; }
.game-stats { display: flex; gap: 16px; }
.stat-box { display: flex; flex-direction: column; }
.stat-label { font-size: 0.7rem; font-weight: 900; color: var(--text-muted); letter-spacing: 0.05em; transition: color 0.3s; }
.stat-value { font-size: 1.3rem; font-weight: 900; color: var(--text-main); line-height: 1; font-variant-numeric: tabular-nums; transition: color 0.3s; }

.ideal-box .stat-label { color: var(--ideal-color); }
.ideal-box .stat-value { color: var(--ideal-color); }

.header-right { display: flex; align-items: center; gap: 8px; }

.btn-icon, .btn-action { display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; border-radius: 12px; font-weight: 800; font-size: 0.95rem; background: transparent; color: var(--text-main); border: 2px solid var(--border); cursor: pointer; transition: all 0.2s ease; text-decoration: none; }
.btn-icon { width: 44px; padding: 0; }
.btn-action { padding: 0 16px; }
.btn-icon:hover, .btn-action:hover { border-color: var(--accent); color: var(--accent); }
.btn-action.active { background: var(--accent) !important; border-color: var(--accent) !important; color: white !important; box-shadow: 0 0 15px var(--accent); transform: scale(0.95); } 

.hint-btn-wrapper { position: relative; display: flex; align-items: center; }
.hint-tooltip { position: absolute; top: calc(100% + 12px); right: 0; background: var(--text-main); color: var(--bg-page); padding: 10px 16px; border-radius: 8px; font-size: 0.85rem; font-weight: 500; white-space: nowrap; opacity: 0; visibility: hidden; transition: 0.2s; transform: translateY(-5px); z-index: 101; box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.hint-tooltip::after { content: ""; position: absolute; bottom: 100%; right: 24px; border-width: 6px; border-style: solid; border-color: transparent transparent var(--text-main) transparent; }
.hint-btn-wrapper:hover .hint-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }

.theme-container { position: relative; }
.theme-palette { position: absolute; top: 55px; right: 0; background: var(--bg-surface); backdrop-filter: blur(20px); padding: 12px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); border: 1px solid var(--border); display: flex; gap: 8px; z-index: 50; }
.theme-swatch { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255,255,255,0.5); transition: 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }
.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch.active { outline: 3px solid var(--text-main); outline-offset: 2px; }

/* 🌟 SWAP 보드 (비율 유동 적용) */
.board-wrapper { 
    position: relative; width: 90vw; max-width: 700px; 
    border-radius: 16px; padding: 8px; 
    background: var(--border-board); 
    border: 2px solid var(--border-board); 
    box-shadow: var(--board-shadow); 
    backdrop-filter: blur(15px); 
}

.empty-slot-bg { 
    position: absolute; top: 8px; left: 8px; right: 8px; bottom: 8px; 
    border-radius: 8px; background: rgba(0,0,0,0.2); 
    box-shadow: inset 0 10px 25px rgba(0,0,0,0.4); z-index: 0; 
}

.puzzle-board { 
    position: relative;
    width: 100%; height: 100%; 
    z-index: 1; 
}

/* 💡 스우시(Swoosh) 애니메이션 타일 */
.swap-tile {
    position: absolute;
    background-size: var(--bg-size-w) var(--bg-size-h); 
    background-repeat: no-repeat;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, z-index 0.2s;
    z-index: 2;
}

/* 선택 시 붕 뜨는 홀로그램 효과 */
.swap-tile.selected { 
    transform: scale(1.08) translateY(-5px); 
    box-shadow: 0 15px 30px rgba(0,0,0,0.6), 0 0 20px var(--accent); 
    z-index: 10 !important; 
    border: 2px solid var(--accent);
}

.hint-overlay { position: absolute; top: 8px; left: 8px; right: 8px; bottom: 8px; border-radius: 8px; background-size: cover; background-position: center; opacity: 0.95; transition: opacity 0.2s; z-index: 20; pointer-events: none; border: 3px solid var(--accent); box-shadow: 0 0 20px var(--accent); }

/* 🌟 모달 */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.3s; padding: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content { background: var(--bg-surface); padding: 30px 24px; border-radius: 24px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 25px 50px rgba(0,0,0,0.3); border: 1px solid var(--border); backdrop-filter: blur(20px); }
.modal-title { font-size: 1.8rem; font-weight: 900; margin-bottom: 20px; color: var(--text-main); letter-spacing: -0.05em; }
.modal-buttons.vertical { display: flex; flex-direction: column; gap: 10px; }

.result-header { margin-bottom: 12px; }
.badge { display: inline-block; background: var(--accent); color: white; font-size: 0.75rem; font-weight: 900; padding: 4px 10px; border-radius: 12px; letter-spacing: 0.05em; margin-bottom: 6px;}
.result-title { font-size: 1.8rem; font-weight: 900; line-height: 1; color: var(--text-main); margin-bottom: 16px;}

.result-theme-selector { display: flex; justify-content: center; gap: 6px; margin-bottom: 16px; background: var(--bg-page); padding: 6px; border-radius: 12px; border: 1px solid var(--border); }
.rt-btn { flex: 1; padding: 8px 0; font-size: 0.8rem; font-weight: 800; border: none; background: transparent; color: var(--text-muted); border-radius: 8px; cursor: pointer; transition: 0.2s; }
.rt-btn.active { background: var(--text-main); color: var(--bg-page); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

.preview-container { margin: 0 auto 20px auto; width: 100%; max-width: 260px; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 20px rgba(0,0,0,0.15); border: 1px solid var(--border); background: transparent; }
#artifactPreview { width: 100%; height: auto; display: block; object-fit: contain; }

.action-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn-save, .btn-share { flex: 1; padding: 14px 10px; border-radius: 50px; font-weight: 900; font-size: 1rem; border: none; cursor: pointer; transition: 0.2s; color: white; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 15px rgba(0,0,0,0.15); }
.btn-save { background: #10B981; }
.btn-save:hover { background: #059669; transform: translateY(-2px); }
.btn-share { background: linear-gradient(135deg, #ec4899, #8b5cf6); } 
.btn-share:hover { filter: brightness(1.1); transform: translateY(-2px); }