/* ===================================
   별과 땅의 이야기 - Enhanced Stylesheet
   이미지 에셋 지원 버전
   =================================== */

/* === CSS Variables === */
:root {
    /* Colors — shared-ui.css 골드 토큰 기반 */
    --bg-top: #0a0a1a;
    --bg-bottom: #12122a;
    --map-outline: var(--sui-gold, #ffd700);
    --hotspot-inactive: #FFE66D;
    --hotspot-active: #FFFFFF;
    --light-beam: rgba(255, 215, 0, 0.6);
    --text-primary: var(--sui-text-primary, #FFFFFF);
    --text-secondary: var(--sui-text-muted, #a0a0b0);

    /* Timing */
    --transition-fast: 200ms;
    --transition-medium: 400ms;
    --transition-slow: 800ms;

    /* Spacing */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
    background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* === Screen Reader Only === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* === Entry Transition + Guide === */
.transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0A1128 0%, #1F2A5A 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.6s ease;
}

.transition-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.transition-text {
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
    position: absolute;
}

.transition-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.transition-text.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}

/* 가이드 콘텐츠 */
.guide-content {
    opacity: 0;
    transition: opacity 0.8s ease;
    max-width: 380px;
    width: calc(100% - 48px);
    text-align: left;
}

.guide-content.visible {
    opacity: 1;
}

.guide-title {
    color: var(--sui-gold, #ffd700);
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: 0.05em;
}

.guide-section {
    margin-bottom: 22px;
}

.guide-section:last-child {
    margin-bottom: 0;
}

.guide-section-title {
    color: var(--sui-gold, #ffd700);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    letter-spacing: 0.5px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 7px 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.88rem;
    line-height: 1.4;
}

.guide-item-icon {
    font-size: 1.1rem;
    min-width: 26px;
    text-align: center;
    flex-shrink: 0;
}

/* 하단 닫기 안내 */
.guide-dismiss {
    position: absolute;
    bottom: calc(var(--sui-footer-height, 28px) + 16px);
    opacity: 0;
    transition: opacity 0.6s ease;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    pointer-events: none;
}

.guide-dismiss.visible {
    opacity: 1;
}

/* === Main Layout === */
main {
    position: relative;
    width: 100%;
    height: calc(100vh - var(--sui-header-height, 52px));
    height: calc(100dvh - var(--sui-header-height, 52px));
    margin-top: var(--sui-header-height, 52px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === Title Zone (고정 헤더) === */
.title-zone {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px var(--spacing-md) 10px;
    opacity: 0;
    animation: slideDown 800ms ease-out 1.8s forwards;
}

.main-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.subtitle {
    font-size: 0.9rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    opacity: 0.7;
}

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

/* === Navigation Bar (뒤로가기 버튼 영역) === */
.nav-bar {
    flex-shrink: 0;
    padding: 0 var(--spacing-md);
}

.back-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin: 4px 0;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    transform: translateX(-2px);
}

.back-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.back-button:active {
    transform: scale(0.97);
}

/* === Layout Container === */
.layout-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* === Map Section === */
.main-canvas,
.map-section {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: flex 0.4s ease;
}

/* === Background Stars === */
.background-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.background-stars::before,
.background-stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow:
        100px 150px 0 0 rgba(255, 255, 255, 0.8),
        250px 280px 0 0 rgba(255, 255, 255, 0.6),
        400px 100px 0 0 rgba(255, 255, 255, 0.7),
        550px 320px 0 0 rgba(255, 255, 255, 0.5),
        150px 450px 0 0 rgba(255, 255, 255, 0.9),
        680px 220px 0 0 rgba(255, 255, 255, 0.6),
        300px 560px 0 0 rgba(255, 255, 255, 0.7),
        480px 380px 0 0 rgba(255, 255, 255, 0.5),
        620px 480px 0 0 rgba(255, 255, 255, 0.8),
        200px 620px 0 0 rgba(255, 255, 255, 0.6),
        750px 150px 0 0 rgba(255, 255, 255, 0.7),
        350px 240px 0 0 rgba(255, 255, 255, 0.5),
        520px 580px 0 0 rgba(255, 255, 255, 0.8),
        180px 340px 0 0 rgba(255, 255, 255, 0.6),
        720px 420px 0 0 rgba(255, 255, 255, 0.7);
    animation: twinkle 4s infinite;
}

.background-stars::after {
    animation-delay: 2s;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* === ENHANCED Korea Map === */
.korea-map-container,
.map-container {
    position: relative;
    width: 100%;
    max-width: 700px;
    height: auto;
    margin: 0 auto;
    z-index: 2;
    opacity: 0;
    animation: mapFadeIn 1s ease-out 0.8s forwards;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image-based map */
.korea-map-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5))
            brightness(1.1)
            contrast(1.2);
    opacity: 0.8;
}

/* SVG-based map with enhanced effects */
.korea-map-svg {
    width: 100%;
    height: auto;
    max-height: 70vh;
    display: block;
}

.map-outline-detailed {
    animation: mapPulse 3s ease-in-out infinite;
}

@keyframes mapPulse {
    0%, 100% {
        opacity: 0.8;
        filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4));
    }
    50% {
        opacity: 1;
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.6));
    }
}

.map-decoration-stars circle {
    animation: decorationTwinkle 3s infinite;
}

@keyframes decorationTwinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes mapFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* === Hotspots - ENHANCED === */
.hotspots-container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 800px;
    z-index: 3;
}

.hotspot {
    position: absolute;
    width: 50px;
    height: 50px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform var(--transition-medium) ease-out;
    opacity: 0;
    animation: hotspotAppear 500ms ease-out forwards;
}

.hotspot:focus {
    outline: 3px solid var(--hotspot-active);
    outline-offset: 4px;
}

.hotspot-glow {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--hotspot-inactive) 0%, transparent 70%);
    animation: hotspotPulse 800ms ease-in-out infinite;
    /* Enhanced glow effect */
    filter: blur(10px);
}

.hotspot.visited .hotspot-glow {
    background: radial-gradient(circle, var(--hotspot-active) 0%, var(--hotspot-active) 20%, transparent 70%);
    animation: visitedGlow 2s ease-in-out infinite;
}

@keyframes visitedGlow {
    0%, 100% {
        filter: blur(8px);
        opacity: 0.8;
    }
    50% {
        filter: blur(12px);
        opacity: 1;
    }
}

.hotspot-star {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(255, 230, 109, 0.8));
    animation: starRotate 4s linear infinite;
}

@keyframes starRotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.hotspot-label {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(31, 42, 90, 0.8));
    padding: 6px 14px;
    border-radius: 14px;
    border: 1px solid var(--sui-border, rgba(255, 215, 0, 0.20));
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hotspot:hover {
    transform: translate(-50%, -50%) scale(1.4);
}

.hotspot:hover .hotspot-label {
    opacity: 1;
}

.hotspot:hover .hotspot-star {
    animation: starRotate 2s linear infinite, starBounce 0.6s ease-in-out;
}

@keyframes starBounce {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
}

@keyframes hotspotPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes hotspotAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* === Light Beams - ENHANCED === */
.light-beam {
    position: absolute;
    width: 4px;
    background: linear-gradient(to top,
        rgba(160, 231, 255, 0.8) 0%,
        rgba(160, 231, 255, 0.6) 30%,
        rgba(160, 231, 255, 0.3) 60%,
        transparent 100%);
    filter: blur(3px);
    box-shadow: 0 0 20px rgba(160, 231, 255, 0.6);
    animation: beamRise 1500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 4;
}

/* Add particle effects to beams */
.light-beam::before,
.light-beam::after {
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    animation: particleRise 1.5s ease-out forwards;
}

.light-beam::before {
    left: -5px;
    animation-delay: 0.2s;
}

.light-beam::after {
    right: -5px;
    animation-delay: 0.4s;
}

@keyframes beamRise {
    from {
        height: 0;
        opacity: 1;
    }
    to {
        height: 100vh;
        opacity: 0;
    }
}

@keyframes particleRise {
    from {
        bottom: 0;
        opacity: 1;
    }
    to {
        bottom: 100%;
        opacity: 0;
    }
}

/* === ENHANCED Constellation Overlay === */
.constellation-overlay {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 700px;
    height: auto;
    aspect-ratio: 1000 / 1200;
    z-index: 5;
    pointer-events: none;
}

.constellation-star {
    fill: white;
    filter: url(#starGlow);
    animation: starAppear 300ms ease-out forwards, starTwinkle 3s ease-in-out infinite;
    opacity: 0;
}

.constellation-image {
    opacity: 0;
    transform-origin: center;
    transition: all 0.3s ease;
}

.constellation-image:hover {
    transform: scale(1.1);
}

.constellation-line {
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 600ms ease-out forwards;
    filter: drop-shadow(0 0 4px currentColor);
}

@keyframes starAppear {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes starTwinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

/* === Progress Zone === */
.progress-zone {
    height: 10vh;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    z-index: 10;
}

.progress-orbs {
    display: flex;
    gap: 14px;
}

.progress-orb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all var(--transition-medium);
    position: relative;
}

.progress-orb::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

.progress-orb.discovered {
    background: radial-gradient(circle, var(--hotspot-active) 0%, var(--hotspot-inactive) 100%);
    border-color: var(--hotspot-active);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.9),
                inset 0 0 10px rgba(255, 255, 255, 0.5);
    animation: orbGlow 400ms ease-out;
}

.progress-orb.discovered::before {
    background: white;
    box-shadow: 0 0 8px white;
}

@keyframes orbGlow {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.6);
        box-shadow: 0 0 30px rgba(255, 255, 255, 1);
    }
    100% {
        transform: scale(1);
    }
}

.progress-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* === Story Modal - ENHANCED === */
.story-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    animation: fadeIn var(--transition-medium);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    background: rgba(10, 10, 26, 0.95);
    border-radius: 20px;
    border: 2px solid var(--sui-border, rgba(255, 215, 0, 0.20));
    padding: var(--spacing-xl);
    overflow-y: auto;
    animation: modalSlideIn var(--transition-medium) ease-out;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                inset 0 0 60px rgba(255, 215, 0, 0.05);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.modal-close:hover {
    background: rgba(255, 100, 100, 0.3);
    border-color: rgba(255, 100, 100, 0.5);
    transform: rotate(90deg) scale(1.1);
}

.modal-close:focus {
    outline: 3px solid var(--hotspot-active);
    outline-offset: 2px;
}

/* === Constellation Animation (패널 내부) === */
.constellation-animation-container {
    width: 100%;
    height: 120px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.06) 0%, transparent 70%);
    border-radius: 10px;
}

.constellation-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px currentColor);
    animation: constellationFloat 4s ease-in-out infinite;
}

@keyframes constellationFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.03); }
}

.constellation-svg {
    width: 100%;
    height: 100%;
}

/* === Story Content (콤팩트) === */
.story-content {
    text-align: center;
}

.region-symbol {
    font-size: 1.8rem;
    margin-bottom: 6px;
    animation: symbolFadeIn 400ms ease-out 200ms both;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));
}

.story-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 2px;
    animation: textSlideIn 400ms ease-out 300ms both;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.story-subtitle {
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 12px;
    animation: textSlideIn 400ms ease-out 400ms both;
}

.story-text {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 14px;
    text-align: left;
}

.story-text p {
    margin-bottom: 6px;
    animation: textSlideIn 400ms ease-out both;
}

.story-text p:nth-child(1) { animation-delay: 500ms; }
.story-text p:nth-child(2) { animation-delay: 600ms; }
.story-text p:nth-child(3) { animation-delay: 700ms; }

/* 28수 대응지역 정보 */
.historical-region-info {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 215, 0, 0.03);
    border: 1px solid rgba(255, 215, 0, 0.12);
    border-radius: 8px;
    animation: textSlideIn 400ms ease-out 800ms both;
}

.historical-region-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #FFD700;
    margin-bottom: 4px;
}

.historical-region-su {
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    opacity: 0.8;
}

.historical-region-area {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.historical-region-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.historical-region-cities {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
    opacity: 0.7;
    display: flex;
    flex-wrap: wrap;
    gap: 3px 6px;
}

.mapping-city {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.72rem;
    white-space: nowrap;
    cursor: default;
    transition: background 0.2s;
}

.mapping-city:hover {
    background: rgba(255, 215, 0, 0.08);
    border-color: rgba(255, 215, 0, 0.2);
}

@keyframes symbolFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-20deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes textSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Audio Player (콤팩트) === */
.audio-player {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px;
    margin-bottom: 10px;
}

.audio-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px;
    background: var(--sui-gold-bg, rgba(255, 215, 0, 0.10));
    border: 1px solid var(--sui-border, rgba(255, 215, 0, 0.20));
    border-radius: 8px;
    color: white;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 6px;
}

.audio-control:hover {
    background: var(--sui-gold-bg-hover, rgba(255, 215, 0, 0.20));
    border-color: var(--sui-gold, #ffd700);
}

.audio-control:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.audio-control.playing {
    background: rgba(255, 215, 0, 0.12);
    border-color: rgba(255, 215, 0, 0.3);
}

.audio-control.playing .audio-icon {
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.audio-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.audio-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #FFD93D, #FFA500);
    width: 0;
    transition: width 100ms linear;
}

.audio-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 4px;
}

/* === Next Story Button (콤팩트) === */
.next-story-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--sui-gold-bg, rgba(255, 215, 0, 0.10));
    border: 1px solid var(--sui-border, rgba(255, 215, 0, 0.20));
    border-radius: var(--sui-radius-pill, 999px);
    color: white;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.next-story-btn:hover {
    background: var(--sui-gold-bg-hover, rgba(255, 215, 0, 0.20));
    border-color: var(--sui-gold, #ffd700);
    color: var(--sui-gold-bright, #ffe766);
    transform: translateY(-1px);
}

.next-story-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* === ENHANCED Completion Overlay === */
.completion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0A1128 0%, #1F2A5A 100%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: completionFadeIn 1s ease-out;
}

.completion-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Option 1: Use actual Cheonsang Yeolcha image */
.cheonsang-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    animation: cheonsangAppear 3s ease-out 1s forwards;
    filter: brightness(1.3) contrast(1.1);
}

@keyframes cheonsangAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 0.7;
        transform: scale(1);
    }
}

/* Option 2: CSS-based star field */
.completion-sky::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 80%, white, transparent),
        radial-gradient(2px 2px at 15% 55%, white, transparent);
    background-size: 200% 200%;
    background-position: 0% 0%;
    animation: skyBrighten 3s ease-out, starMove 20s linear infinite;
}

@keyframes completionFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes skyBrighten {
    from {
        opacity: 0;
        filter: brightness(0.5);
    }
    to {
        opacity: 1;
        filter: brightness(1.8);
    }
}

@keyframes starMove {
    from {
        background-position: 0% 0%;
    }
    to {
        background-position: 100% 100%;
    }
}

.completion-content {
    position: relative;
    text-align: center;
    padding: var(--spacing-xl);
    opacity: 0;
    animation: completionTextAppear 1s ease-out 2.5s forwards;
    z-index: 1;
}

.completion-title {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.8),
                 0 0 20px rgba(255, 215, 0, 0.5);
    letter-spacing: 0.05em;
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.6),
                     0 0 15px rgba(255, 215, 0, 0.4);
    }
    50% {
        text-shadow: 0 0 50px rgba(255, 255, 255, 1),
                     0 0 25px rgba(255, 215, 0, 0.7);
    }
}

.completion-subtitle {
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    letter-spacing: 0.08em;
}

@keyframes completionTextAppear {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.return-btn {
    padding: var(--spacing-md) var(--spacing-xl);
    background: linear-gradient(135deg, var(--sui-gold-dim, #c9a962), var(--sui-gold, #ffd700));
    border: 3px solid rgba(255, 215, 0, 0.4);
    border-radius: var(--sui-radius-pill, 999px);
    color: #0a0a1a;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 6px 24px rgba(255, 215, 0, 0.3);
    opacity: 0;
    animation: buttonAppear 500ms ease-out 3.5s forwards;
}

.return-btn:hover {
    background: linear-gradient(135deg, var(--sui-gold, #ffd700), var(--sui-gold-bright, #ffe766));
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 10px 35px rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.6);
}

.return-btn:focus {
    outline: 3px solid var(--hotspot-active);
    outline-offset: 4px;
}

@keyframes buttonAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* === Credit Footer === */
.credit-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 3px 0;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
}

.credit-footer a {
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
}

.credit-footer a:hover {
    color: rgba(255, 255, 255, 0.7);
}

/* === Story Panel (인-플로우, 지도와 공존) === */
.story-panel {
    position: relative;
    flex: 0 0 0;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    border: none;
    background: rgba(10, 10, 26, 0.90);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: flex-basis 0.4s ease, opacity 0.3s ease 0.1s, padding 0.4s ease;
    order: -1; /* 좌측 사이드바로 배치 */
}

.story-panel.open {
    flex: 0 0 25%;
    min-width: 300px;
    max-width: 420px;
    opacity: 1;
    padding: 20px 24px;
    overflow-y: auto;
    margin: 10px 0 calc(var(--sui-footer-height, 28px) + 10px) 10px;
    border-radius: var(--sui-radius-md, 10px);
    border: 1px solid var(--sui-border-panel, rgba(255, 215, 0, 0.12));
    border-right: 2px solid var(--sui-border-panel, rgba(255, 215, 0, 0.12));
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.3);
}

/* 스토리 패널 스크롤바 */
.story-panel::-webkit-scrollbar {
    width: 4px;
}

.story-panel::-webkit-scrollbar-track {
    background: transparent;
}

.story-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.panel-close:hover {
    background: rgba(255, 100, 100, 0.15);
    color: white;
}

.panel-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* === Responsive Design === */

/* Tablet Landscape */
@media (max-width: 1279px) {
    .main-title { font-size: 1.6rem; }
    .korea-map-container { max-width: 550px; }
    .hotspots-container { width: 550px; height: 700px; }
    .constellation-overlay { width: 550px; height: 700px; }
}

/* Tablet Portrait */
@media (max-width: 1023px) {
    .main-title { font-size: 1.4rem; }
    .korea-map-container { max-width: 450px; }
    .hotspots-container { width: 450px; height: 600px; }
    .constellation-overlay { width: 450px; height: 600px; }
    .modal-content { max-width: 550px; }

    .story-panel.open {
        flex: 0 0 40%;
        min-width: 280px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    /* --- 헤더 --- */
    .title-zone {
        padding: 10px 16px 6px;
    }

    .main-title { font-size: 1.2rem; margin-bottom: 0; }
    .subtitle { display: none; }

    /* --- 수직 레이아웃 --- */
    .layout-container {
        flex-direction: column;
    }

    /* --- 지도 --- */
    .korea-map-container,
    .map-container {
        width: 100%;
        max-width: none;
        height: 100%;
        padding: 4px;
    }

    .korea-map-svg {
        max-height: none;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .hotspots-container { width: 100%; max-width: none; height: auto; }
    .constellation-overlay { width: 100%; max-width: none; }

    /* --- 스토리 패널: 모바일 카드 (하단 배치) --- */
    .story-panel {
        order: 1; /* 모바일에서는 지도 아래 */
    }

    .story-panel.open {
        flex: 0 0 55%;
        min-width: auto;
        max-width: none;
        margin: 0 6px calc(var(--sui-footer-height, 28px) + 6px);
        padding-bottom: 24px;
        border-radius: 16px 16px 12px 12px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3),
                    inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }

    /* X 닫기 버튼: 모바일에서 sticky로 항상 보이도록 */
    .story-panel .panel-close {
        position: sticky;
        top: 0;
        float: right;
        margin: 0 0 -24px 0;
        z-index: 20;
    }

    .story-panel .constellation-animation-container {
        height: 80px;
        margin-bottom: 8px;
    }

    .story-panel .region-symbol { font-size: 1.4rem; margin-bottom: 4px; }
    .story-panel .story-title { font-size: 1.05rem; }
    .story-panel .story-subtitle { font-size: 0.8rem; margin-bottom: 8px; }
    .story-panel .story-text { font-size: 0.82rem; margin-bottom: 10px; }

    .modal-content {
        width: 95%;
        padding: var(--spacing-lg);
    }

    /* --- 완료 화면 --- */
    .completion-title { font-size: 1.5rem; line-height: 1.4; }
    .completion-subtitle { font-size: 0.95rem; }
    .completion-content { padding: var(--spacing-lg) var(--spacing-md); }

    /* --- 인트로 전환 --- */
    .transition-text {
        font-size: 1.1rem;
        padding: 0 24px;
        text-align: center;
        line-height: 1.8;
    }
}

/* Mobile Small */
@media (max-width: 413px) {
    .main-title { font-size: 1.05rem; }
    .story-panel .story-title { font-size: 0.95rem; }
    .completion-title { font-size: 1.3rem; }
    .transition-text { font-size: 0.95rem; }
}

/* Reduced Motion */
/* 모바일 가이드 */
@media (max-width: 500px) {
    .guide-content {
        max-width: 300px;
    }

    .guide-title {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    .guide-item {
        font-size: 0.8rem;
        gap: 10px;
        padding: 5px 0;
    }

    .guide-item-icon {
        font-size: 0.95rem;
        min-width: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
