/* ===== CSS Variables ===== */
:root {
    --color-bg: #0a0a1a;
    --color-bg-panel: var(--sui-bg-panel, #12122a);
    --color-text: var(--sui-text-primary, #ffffff);
    --color-text-dim: var(--sui-text-muted, #a0a0b0);
    --color-accent: var(--sui-gold, #ffd700);
    --color-accent-hover: var(--sui-gold-bright, #ffe766);
    --color-border: var(--sui-border-hard, #2a2a4a);
    --color-progress: var(--sui-gold, #ffd700);
    --color-marker-active: var(--sui-gold-bright, #ffe766);

    --panel-width: 360px;
    --font-size-base: 16px;
    --font-size-title: 1.5rem;
    --font-size-description: 1rem;

    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    --transition-slow: 0.5s ease;

    --z-intro: 2000;
    --z-loading: 1000;
    --z-panel: 100;
    --z-progress: 90;
    --z-hint: 80;
    --z-cta: 110;
    --z-accessibility: 120;
}

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

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* 헤더 영역 확보 - body에만 적용 */
    padding-top: var(--sui-header-height, 52px);
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: var(--font-size-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Intro Screen ===== */
.intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-bg) 0%, #0f0f1a 50%, var(--color-bg-panel) 100%);
    z-index: var(--z-intro);
    transition: opacity 1s ease, visibility 1s ease;
}

.intro-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#intro-starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.intro-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.intro-line {
    font-family: 'Noto Serif KR', serif;
    font-size: clamp(1.2rem, 3.5vw, 2rem);
    font-weight: 300;
    line-height: 1.8;
    text-align: center;
    color: var(--color-text);
    opacity: 0;
    position: absolute;
    max-width: 90%;
    letter-spacing: 0.05em;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.4), 0 0 60px rgba(255, 215, 0, 0.2);
}

.intro-line.emphasis {
    font-weight: 600;
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    letter-spacing: 0.1em;
    color: var(--color-accent);
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.6), 0 0 80px rgba(255, 215, 0, 0.3);
}

.intro-start-button {
    opacity: 0;
    padding: 18px 45px;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-family: 'Noto Serif KR', serif;
    font-weight: 400;
    color: #ffffff;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
    letter-spacing: 0.1em;
    position: absolute;
    pointer-events: none;
}

.intro-start-button.visible {
    opacity: 1;
    pointer-events: auto;
}

.intro-start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 50px rgba(255, 215, 0, 0.6), 0 0 30px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, var(--color-accent-hover) 0%, #ffe766 100%);
    border-color: rgba(255, 215, 0, 0.5);
}

.intro-start-button:active {
    transform: translateY(-1px);
}

.intro-skip-button {
    position: absolute;
    bottom: calc(var(--sui-footer-height, 28px) + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    font-size: 0.9rem;
    font-family: 'Noto Serif KR', serif;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
}

.intro-skip-button:hover {
    color: #fff;
    background: rgba(255, 215, 0, 0.3);
    border-color: rgba(255, 215, 0, 0.5);
}

@media (max-width: 768px) {
    .intro-line {
        max-width: 95%;
    }

    .intro-skip-button {
        bottom: calc(var(--sui-footer-height, 28px) + 6px);
        padding: 8px 16px;
        font-size: 0.8rem;
    }
}

/* ===== Loading Screen → shared-ui.css .sui-loading 사용 ===== */

/* ===== App Container ===== */
.app-container {
    width: 100%;
    height: 100%;
    position: relative;
    transition: opacity var(--transition-slow);
}

.app-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== Model Area (wrapper for canvas + progress) ===== */
.model-area {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ===== WebGL Canvas ===== */
.webgl-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    outline: none;
}

/* ===== Info Panel ===== */
.info-panel {
    position: fixed;
    top: var(--sui-header-height, 52px);
    right: 0;
    bottom: calc(var(--sui-footer-height, 28px) + 80px);
    width: var(--panel-width);
    background: rgba(10, 10, 26, 0.85);
    border-left: 1px solid var(--sui-border-panel, rgba(255,215,0,0.12));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: var(--z-panel);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-medium);
    overflow: hidden;
}

.info-panel.closed {
    transform: translateX(calc(var(--panel-width) - 40px));
}

.panel-toggle {
    position: absolute;
    top: 50%;
    left: -40px;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    font-size: 1.2rem;
    transition: background var(--transition-fast);
}

.panel-toggle:hover {
    background: var(--color-border);
}

.panel-toggle .toggle-icon {
    transition: transform var(--transition-fast);
}

.info-panel.closed .toggle-icon {
    transform: rotate(180deg);
}

.panel-content {
    padding: 4.5rem 1.5rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-title {
    font-size: var(--font-size-title);
    margin-bottom: 1rem;
    color: var(--color-accent);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.panel-description {
    font-size: var(--font-size-description);
    line-height: 1.8;
    white-space: pre-line;
    flex: 1;
    overflow-y: auto;
    padding-bottom: 2rem;
}

.panel-description strong {
    color: var(--color-accent);
    font-weight: 600;
}

/* ===== Progress Bar ===== */
.progress-container {
    position: fixed;
    bottom: var(--sui-footer-height, 28px);
    left: 0;
    right: 0;
    padding: 1.5rem 2rem;
    z-index: var(--z-progress);
    background: linear-gradient(to top, rgba(10, 10, 15, 0.9), transparent);
    pointer-events: none;
}

.progress-markers {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 0.5rem;
}

.progress-marker {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    pointer-events: auto;
    cursor: pointer;
}

.marker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-border);
    border: 2px solid var(--color-bg);
    transition: all var(--transition-medium);
    position: relative;
    z-index: 2;
}

.progress-marker.active .marker-dot {
    background: var(--color-marker-active);
    box-shadow: 0 0 12px var(--color-marker-active);
    animation: pulse 2s ease-in-out infinite;
}

.progress-marker.completed .marker-dot {
    background: var(--color-progress);
}

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

.marker-label {
    font-size: 0.75rem;
    color: var(--color-text-dim);
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.progress-marker.active .marker-label {
    color: var(--color-marker-active);
    font-weight: 600;
}

.progress-marker.completed .marker-label {
    color: var(--color-progress);
}

.progress-line {
    width: 100%;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-progress), var(--color-accent-hover));
    width: 0%;
    transition: width var(--transition-medium);
}

/* ===== Controls Hint ===== */
.controls-hint {
    position: fixed;
    bottom: calc(var(--sui-footer-height, 28px) + 120px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 46, 0.9);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    z-index: var(--z-hint);
    transition: opacity var(--transition-slow);
    pointer-events: none;
}

.controls-hint.hidden {
    opacity: 0;
}

.hint-content {
    font-size: 0.9rem;
    color: var(--color-text-dim);
}

.hint-mobile {
    display: none;
}

.hint-content strong {
    color: var(--color-text);
}

/* ===== Tutorial Container ===== */
.tutorial-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 10, 26, 0.92);
    border: 2px solid var(--color-accent);
    border-radius: 20px;
    padding: 3rem 2.5rem;
    max-width: 600px;
    width: 85%;
    z-index: 250;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 15px 50px rgba(255, 215, 0, 0.25);
    transition: opacity var(--transition-medium), transform var(--transition-medium);
    text-align: center;
    pointer-events: auto;
    touch-action: none;
}

.tutorial-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.9);
}

.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
    position: relative;
}

.tutorial-badge {
    background: var(--color-accent);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.tutorial-step {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text-dim);
    font-size: 1rem;
    font-weight: 600;
}

.tutorial-skip-btn {
    position: absolute;
    top: -1rem;
    right: -1rem;
    background: rgba(255, 70, 70, 0.9);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(255, 70, 70, 0.4);
    z-index: 10;
}

.tutorial-skip-btn:hover {
    background: rgba(255, 50, 50, 1);
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(255, 70, 70, 0.6);
}

.tutorial-skip-btn:active {
    transform: scale(0.95);
}

.tutorial-icon {
    font-size: 4rem;
    margin: 1rem 0;
    animation: tutorial-pulse 2s ease-in-out infinite;
}

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

.tutorial-title {
    font-size: 2rem;
    color: var(--color-accent);
    margin: 0;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.tutorial-text {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--color-text);
}

.tutorial-instruction {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #ffaa44;
    font-weight: 600;
    padding: 1.5rem 2rem;
    background: rgba(255, 170, 68, 0.15);
    border: 2px solid #ffaa44;
    border-radius: 12px;
    margin-top: 1rem;
}

.tutorial-skip-hint {
    font-size: 0.9rem;
    color: var(--color-text-dim);
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* === 튜토리얼 모바일 세로 모드 축소 === */
@media (max-width: 768px) and (orientation: portrait) {
    .tutorial-container {
        padding: 1.5rem 1.2rem;
        width: 80%;
        max-width: 360px;
    }
    .tutorial-content {
        gap: 0.8rem;
    }
    .tutorial-badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.9rem;
    }
    .tutorial-step {
        font-size: 0.8rem;
    }
    .tutorial-icon {
        font-size: 2.5rem;
        margin: 0.5rem 0;
    }
    .tutorial-title {
        font-size: 1.3rem;
    }
    .tutorial-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    .tutorial-instruction {
        font-size: 0.85rem;
        line-height: 1.5;
        padding: 0.8rem 1rem;
        margin-top: 0.5rem;
    }
    .tutorial-skip-hint {
        font-size: 0.75rem;
    }
    .tutorial-skip-btn {
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
        top: -0.8rem;
        right: -0.8rem;
    }
}

/* ===== Center Description Container ===== */
.center-description {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 10, 26, 0.92);
    border: 2px solid var(--color-accent);
    border-radius: 20px;
    padding: 3rem 2.5rem;
    max-width: 1000px;
    width: 85%;
    z-index: 200;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.2);
    transition: opacity var(--transition-medium), transform var(--transition-medium);
    text-align: left;
    pointer-events: auto;
    touch-action: none;
}

.center-description.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.95);
}


.center-description-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: stretch;
}

.center-title {
    font-size: 2rem;
    color: var(--color-accent);
    margin: 0;
    letter-spacing: 0.05em;
    text-align: center;
}

.center-text {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--color-text);
    white-space: pre-line;
}

.dismiss-btn {
    margin-top: 1rem;
    padding: 1rem 2.5rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    align-self: center;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.dismiss-btn:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
}

.dismiss-icon {
    font-size: 1.3rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(5px);
    }
}

/* ===== Description Info Button (mobile portrait only) ===== */
.desc-info-btn {
    display: none; /* 데스크톱/가로 모드에서 숨김 */
}

.gesture-hint {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text-dim);
    opacity: 0.8;
    text-align: center;
}

/* ===== Quiz Container ===== */
.quiz-container {
    position: fixed;
    bottom: 100px;
    left: 30px;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    width: 500px;
    max-width: 90%;
    z-index: 150;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: opacity var(--transition-medium), transform var(--transition-medium);
    pointer-events: none; /* Allow touches to pass through to canvas */
    transform: none;
    box-sizing: border-box;
}

.quiz-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px);
}

.quiz-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: auto; /* Enable touches on quiz UI elements */
}

.quiz-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.3rem;
}

.quiz-question {
    font-size: 1.3rem;
    color: var(--color-accent);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 215, 0, 0.6);
}

.quiz-option:active {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--color-accent);
    transform: scale(0.97);
}

.option-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent);
    min-width: 30px;
}

.option-text {
    font-size: 1.1rem;
    color: var(--color-text);
    line-height: 1.4;
}

.quiz-hint {
    font-size: 1.1rem;
    color: #ffaa44;
    font-weight: 500;
    padding: 1rem 1.5rem;
    background: rgba(255, 170, 68, 0.15);
    border: 2px solid #ffaa44;
    border-radius: 8px;
    text-align: center;
    animation: quiz-pulse 2s ease-in-out infinite;
}

.quiz-touch-hint {
    font-size: 0.78rem;
    color: var(--color-text-dim);
    text-align: center;
    margin-top: 0.3rem;
}

@keyframes quiz-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.9;
    }
}

.quiz-feedback {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    transition: all var(--transition-fast);
}

.quiz-feedback.correct {
    background: rgba(76, 175, 80, 0.2);
    border: 2px solid #4CAF50;
    color: #4CAF50;
}

.quiz-feedback.wrong {
    background: rgba(244, 67, 54, 0.2);
    border: 2px solid #f44336;
    color: #f44336;
}

.quiz-controls {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.quiz-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quiz-btn:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
}

.quiz-btn.skip-btn {
    background: var(--color-border);
    color: var(--color-text);
}

.quiz-btn.skip-btn:hover {
    background: var(--color-text-dim);
}

/* ===== Season CTA ===== */
.season-cta {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.95);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid var(--color-accent);
    max-width: 500px;
    z-index: var(--z-cta);
    text-align: center;
    transition: opacity var(--transition-medium), transform var(--transition-medium);
}

.season-cta.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: none;
}

.cta-content h3 {
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: 1rem;
}

.cta-content p {
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.cta-button {
    background: var(--color-accent);
    color: #fff;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cta-button:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.cta-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--color-text-dim);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 1;
}
.cta-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text);
}

/* ===== Navigation Arrows ===== */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 64px;
    background: rgba(10, 10, 26, 0.6);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    color: var(--color-accent);
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 95;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
}
.nav-arrow:hover {
    background: rgba(10, 10, 26, 0.8);
    border-color: var(--color-accent);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
}
.nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}
.nav-arrow-left {
    left: 0.5rem;
}
.nav-arrow-right {
    right: 0.5rem;
}
.nav-arrow.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== Accessibility Controls ===== */
.accessibility-controls {
    position: fixed;
    top: calc(var(--sui-header-height, 52px) + 1rem);
    left: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: var(--z-accessibility);
}

.accessibility-button {
    width: 40px;
    height: 40px;
    background: rgba(26, 26, 46, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.accessibility-button:hover {
    background: var(--color-border);
    transform: scale(1.05);
}

/* ===== Mobile Portrait: 하단 설명 패널 (데스크톱 숨김) ===== */
.mobile-desc-panel {
    display: none;
}
.mobile-desc-panel.hidden {
    display: none !important;
}

/* ===== Mobile Quiz Button (데스크톱 숨김) ===== */
.mobile-quiz-btn {
    display: none;
}

/* ===== Hand Gesture Panel ===== */
.hand-gesture-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: var(--z-accessibility);
}

.gesture-toggle {
    width: 50px;
    height: 50px;
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    color: var(--color-text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gesture-toggle:hover {
    background: var(--color-accent);
    transform: scale(1.1);
}

.gesture-toggle.active {
    background: var(--color-accent);
    box-shadow: 0 0 20px var(--color-accent);
    animation: gesture-pulse 2s ease-in-out infinite;
}

@keyframes gesture-pulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--color-accent);
    }
    50% {
        box-shadow: 0 0 30px var(--color-accent), 0 0 40px rgba(255, 199, 0, 0.5);
    }
}

.gesture-content {
    position: absolute;
    top: 60px;
    left: 0;
    width: 350px;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: opacity var(--transition-medium), transform var(--transition-medium);
}

.gesture-content.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.gesture-content h3 {
    font-size: 1.2rem;
    color: var(--color-accent);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.gesture-content h4 {
    font-size: 1rem;
    color: var(--color-text);
    margin: 1rem 0 0.5rem 0;
}

.camera-select {
    margin-bottom: 1rem;
}

.camera-select label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text-dim);
}

.camera-select select {
    width: 100%;
    padding: 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text);
    font-size: 0.9rem;
}

.gesture-status {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: 4px;
}

.gesture-status p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
    color: var(--color-text-dim);
}

.gesture-guide ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem 0;
}

.gesture-guide li {
    padding: 0.5rem 0;
    font-size: 0.85rem;
    line-height: 1.4;
    border-bottom: 1px solid var(--color-border);
}

.gesture-guide li:last-child {
    border-bottom: none;
}

.gesture-guide strong {
    color: var(--color-accent);
}

.video-preview {
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.video-preview canvas {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Responsive Design: 모바일 공통 ===== */
/* 세로(width<=768) 또는 가로(height<=500 and width<=1024) */
@media (max-width: 768px), (max-height: 500px) and (max-width: 1024px) {
    /* --- 데스크톱 전용 UI 숨김 --- */
    .info-panel {
        display: none !important;
    }
    .hand-gesture-panel {
        display: none !important;
    }
    .gesture-hint {
        display: none !important;
    }
    .tutorial-container {
        display: none !important;
    }
    .center-description {
        display: none !important;
    }
    .desc-info-btn {
        display: none !important;
    }
    .controls-hint {
        display: none !important;
    }

    .marker-label {
        font-size: 0.65rem;
    }

    .hint-desktop {
        display: none;
    }

    .hint-mobile {
        display: block;
    }

    .season-cta {
        left: 1rem;
        right: 1rem;
        transform: translateY(-50%);
        padding: 1.5rem;
        max-width: none;
    }

    .season-cta.hidden {
        transform: translate(-50%, -50%) scale(0.9);
    }

    .accessibility-controls {
        top: 0.5rem;
        left: 0.5rem;
    }

    .accessibility-button {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
}

/* ===== 모바일 가로: 좌우 분할 ===== */
/* height<=500 and landscape → 모바일 가로모드 (896x414 등) */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1024px) {

    /* --- 전체 레이아웃: 좌우 분할 --- */
    .app-container {
        display: flex;
        flex-direction: row;
        height: 100%;
        overflow: hidden;
    }

    /* --- 좌측: 설명 패널 (40%) --- */
    .mobile-desc-panel {
        display: flex !important;
        flex-direction: column;
        width: 40%;
        min-width: 40%;
        height: 100%;
        padding: 0.6rem 0.8rem;
        padding-bottom: calc(var(--sui-footer-height, 28px) + 4px);
        background: rgba(10, 10, 26, 0.98);
        border-right: 1px solid var(--color-border);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
        touch-action: pan-y;
    }
    .mobile-desc-panel.hidden {
        display: flex !important;
    }
    .mobile-desc-title {
        font-size: clamp(0.75rem, 2vw, 0.95rem);
        font-weight: 600;
        color: var(--color-accent);
        margin-bottom: 0.3rem;
        flex-shrink: 0;
        word-break: keep-all;
    }
    .mobile-desc-text {
        font-size: clamp(0.6rem, 1.6vw, 0.78rem);
        line-height: 1.45;
        color: var(--color-text);
        white-space: pre-line;
        flex: 1;
        overflow-y: auto;
        word-break: keep-all;
        overflow-wrap: break-word;
    }
    .mobile-quiz-btn {
        display: inline-block;
        align-self: center;
        margin-top: 0.4rem;
        padding: 0.3rem 1rem;
        background: transparent;
        border: 1.5px solid var(--color-accent);
        border-radius: 20px;
        color: var(--color-accent);
        font-size: clamp(0.6rem, 1.6vw, 0.78rem);
        font-weight: 600;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.2s;
    }
    .mobile-quiz-btn:active {
        background: rgba(255, 215, 0, 0.15);
    }
    .mobile-quiz-btn.hidden {
        display: none !important;
    }

    /* --- 우측: 모델 영역 (60%) --- */
    .model-area {
        width: 60%;
        height: 100%;
        position: relative;
        display: flex;
        flex-direction: column;
    }

    .webgl-canvas {
        position: relative !important;
        width: 100% !important;
        height: 100% !important;
        flex: 1;
    }

    /* --- 프로그레스바: 모델 영역 하단 --- */
    .progress-container {
        position: relative !important;
        bottom: auto !important;
        padding: 0.4rem 0.6rem;
        background: rgba(10, 10, 15, 0.95);
        flex-shrink: 0;
        border-top: 1px solid var(--color-border);
    }

    /* --- 네비게이션 화살표: 모델 영역 내 절대 위치, 캔버스 중앙 --- */
    .nav-arrow {
        position: absolute !important;
        /* 캔버스 영역의 상하 중앙 (프로그레스바 제외) */
        top: 50%;
        transform: translateY(-50%);
        width: 28px;
        height: 44px;
        font-size: 1.2rem;
        border-radius: 6px;
    }
    .nav-arrow:active {
        transform: translateY(-50%) scale(0.95);
    }
    .nav-arrow-left {
        left: 0.3rem;
    }
    .nav-arrow-right {
        right: 0.3rem;
    }

    /* --- 퀴즈: 좌측 패널 안 인라인 --- */
    .quiz-container {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        bottom: auto !important;
        transform: none !important;
        max-width: 100%;
        width: 100% !important;
        padding: 0.3rem 0;
        max-height: none;
        border: none;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
        z-index: auto;
        pointer-events: auto;
        overflow: visible;
        box-sizing: border-box;
    }
    .quiz-container.hidden {
        display: none !important;
        transform: none !important;
    }
    .quiz-content {
        gap: 0.2rem;
    }
    .quiz-question {
        font-size: clamp(0.6rem, 1.8vw, 0.78rem);
        margin-bottom: 0.15rem;
        line-height: 1.35;
        word-break: keep-all;
        overflow-wrap: break-word;
    }
    .quiz-option {
        padding: 0.25rem 0.4rem;
        gap: 0.2rem;
        border-width: 1.5px;
        border-radius: 8px;
    }
    .option-number {
        font-size: clamp(0.6rem, 1.6vw, 0.75rem);
        min-width: 14px;
        flex-shrink: 0;
    }
    .option-text {
        font-size: clamp(0.55rem, 1.5vw, 0.7rem);
        line-height: 1.3;
        word-break: keep-all;
        overflow-wrap: break-word;
    }
    .quiz-hint {
        font-size: clamp(0.5rem, 1.4vw, 0.65rem);
        padding: 0.2rem 0.3rem;
        word-break: keep-all;
        overflow-wrap: break-word;
    }
    .quiz-feedback {
        font-size: clamp(0.5rem, 1.4vw, 0.65rem);
        padding: 0.2rem 0.3rem;
        min-height: auto;
        word-break: keep-all;
        overflow-wrap: break-word;
    }
    .quiz-btn {
        padding: 0.2rem 0.4rem;
        font-size: clamp(0.55rem, 1.4vw, 0.65rem);
    }
    .quiz-controls {
        gap: 0.4rem;
        margin-top: 0.2rem;
    }
}

@media (max-width: 480px) {
    .panel-title {
        font-size: 1.2rem;
    }

    .panel-description {
        font-size: 0.9rem;
    }

    .progress-marker {
        gap: 0.3rem;
    }

    .marker-dot {
        width: 10px;
        height: 10px;
    }

    .marker-label {
        font-size: 0.6rem;
    }
}

/* ===== High Contrast Mode for Accessibility ===== */
@media (prefers-contrast: high) {
    :root {
        --color-bg: #000;
        --color-text: #fff;
        --color-border: #fff;
    }

    .marker-dot,
    .progress-line {
        border: 2px solid #fff;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Font Size Adjustments ===== */
body.font-size-large {
    --font-size-base: 18px;
    --font-size-title: 1.75rem;
    --font-size-description: 1.1rem;
}

body.font-size-small {
    --font-size-base: 14px;
    --font-size-title: 1.3rem;
    --font-size-description: 0.9rem;
}

/* ===== Focus Styles for Accessibility ===== */
button:focus-visible,
.progress-marker:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
}

/* === 모바일 세로 모드: 상하 분할 레이아웃 === */
@media (max-width: 768px) and (orientation: portrait) {

    /* --- 전체 레이아웃: 상하 분할 --- */
    .app-container {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    /* --- 모델 영역: 상단 (캔버스+프로그레스만큼만 차지, 기본 height:100% 오버라이드) --- */
    .model-area {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        height: auto !important;
    }

    .webgl-canvas {
        position: relative !important;
        width: 100% !important;
        height: 50vh !important;
        flex-shrink: 0;
    }

    /* --- 프로그레스바: 캔버스 아래 고정 --- */
    .progress-container {
        position: relative !important;
        bottom: auto !important;
        padding: 0.5rem 1rem;
        background: rgba(10, 10, 15, 0.95);
        flex-shrink: 0;
        border-top: 1px solid var(--color-border);
        border-bottom: 1px solid var(--color-border);
    }

    /* --- 하단 설명 패널 --- */
    .mobile-desc-panel {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        padding: 0.8rem 1rem;
        padding-bottom: calc(var(--sui-footer-height, 28px) + 8px);
        background: rgba(10, 10, 26, 0.98);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        order: 1;
    }
    .mobile-desc-panel.hidden {
        display: flex !important;
    }
    .mobile-desc-title {
        font-size: 1rem;
        font-weight: 600;
        color: var(--color-accent);
        margin-bottom: 0.5rem;
        flex-shrink: 0;
    }
    .mobile-desc-text {
        font-size: 0.82rem;
        line-height: 1.6;
        color: var(--color-text);
        white-space: pre-line;
        flex: 1;
        overflow-y: auto;
    }
    .mobile-quiz-btn {
        display: inline-block;
        align-self: center;
        margin-top: 0.6rem;
        padding: 0.5rem 1.5rem;
        background: transparent;
        border: 1.5px solid var(--color-accent);
        border-radius: 20px;
        color: var(--color-accent);
        font-size: 0.82rem;
        font-weight: 600;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.2s;
    }
    .mobile-quiz-btn:active {
        background: rgba(255, 215, 0, 0.15);
    }
    .mobile-quiz-btn.hidden {
        display: none !important;
    }

    /* --- 네비게이션 화살표: 모델 영역 내 절대 위치, 캔버스 중앙 --- */
    .nav-arrow {
        position: absolute !important;
        /* 캔버스 50vh의 중앙 = 25vh */
        top: 25vh;
        transform: translateY(-50%);
        width: 32px;
        height: 48px;
        font-size: 1.3rem;
        border-radius: 6px;
    }
    .nav-arrow:active {
        transform: translateY(-50%) scale(0.95);
    }
    .nav-arrow-left {
        left: 0.3rem;
    }
    .nav-arrow-right {
        right: 0.3rem;
    }

    /* --- 퀴즈: 하단 패널 안 인라인 --- */
    .quiz-container {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        bottom: auto !important;
        transform: none !important;
        max-width: 100%;
        width: 100%;
        padding: 0.8rem;
        max-height: none;
        border: none;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
        z-index: auto;
        pointer-events: auto;
    }
    .quiz-container.hidden {
        display: none !important;
        transform: none !important;
    }
    .quiz-content {
        gap: 0.4rem;
    }
    .quiz-question {
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
        line-height: 1.4;
    }
    .quiz-option {
        padding: 0.5rem 0.7rem;
        gap: 0.4rem;
    }
    .option-number {
        font-size: 1rem;
        min-width: 20px;
    }
    .option-text {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    .quiz-hint {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
    .quiz-feedback {
        font-size: 0.78rem;
        padding: 0.4rem 0.6rem;
        min-height: auto;
    }
    .quiz-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* ===== Desktop Sidebar Layout (>=769px) ===== */
@media (min-width: 769px) and (min-height: 501px) {
    /* --- App Container: left sidebar + right model --- */
    .app-container {
        display: flex;
        flex-direction: row;
        height: calc(100vh - var(--sui-header-height, 52px) - var(--sui-footer-height, 28px));
        height: calc(100dvh - var(--sui-header-height, 52px) - var(--sui-footer-height, 28px));
        /* body padding-top이 이미 헤더 공간 확보 → margin-top 제거 */
    }

    /* --- Info Panel: becomes left sidebar (25%) --- */
    .info-panel {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        width: 25%;
        min-width: 300px;
        max-width: 420px;
        height: 100%;
        border-left: none;
        border-right: 2px solid var(--color-border);
        z-index: 50;
        display: flex;
        flex-direction: column;
        transform: none !important;
        order: -1;
    }

    .info-panel.hidden {
        display: flex !important;
        visibility: visible;
        opacity: 1;
    }

    /* Hide toggle button on desktop sidebar */
    .panel-toggle {
        display: none;
    }

    /* Panel content: takes 60% of sidebar */
    .panel-content {
        padding: 1.5rem;
        flex: 6;
        min-height: 0;
        overflow-y: auto;
    }

    .panel-title {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }

    .panel-description {
        font-size: 0.95rem;
        line-height: 1.7;
        padding-bottom: 1rem;
    }

    /* --- Quiz Container: bottom 40% of sidebar --- */
    .quiz-container {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        right: auto;
        width: 100%;
        max-width: 100%;
        flex: 4;
        min-height: 0;
        padding: 1.2rem 1.5rem;
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--color-border);
        background: rgba(10, 10, 26, 0.6);
        backdrop-filter: none;
        box-shadow: none;
        z-index: 50;
        pointer-events: auto;
        transform: none;
        overflow-y: auto;
    }

    .quiz-container.hidden {
        display: none !important;
        transform: none;
    }

    /* Quiz label header */
    .quiz-label {
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--color-accent);
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-bottom: 0.4rem;
        padding-bottom: 0.3rem;
        border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    }

    .quiz-question {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
        line-height: 1.4;
    }

    .quiz-options {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .quiz-option {
        padding: 0.6rem 0.8rem;
        gap: 0.5rem;
    }

    .option-number {
        font-size: 1.1rem;
        min-width: 24px;
    }

    .option-text {
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .quiz-hint {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }

    .quiz-feedback {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }

    /* Hide skip button on desktop sidebar */
    .quiz-controls {
        display: none;
    }

    /* --- Model Area: takes remaining 75% --- */
    .model-area {
        flex: 1;
        height: 100%;
        position: relative;
    }

    /* --- Center Description: hide on desktop (use sidebar instead) --- */
    .center-description {
        display: none !important;
    }

    /* --- Progress Bar: stays inside model-area bottom with spacing --- */
    .progress-container {
        position: absolute;
        bottom: 20px;
        left: 0;
        right: 0;
        padding: 1rem 3rem;
    }

    /* --- 단계 라벨 표시 보강 --- */
    .marker-label {
        font-size: 0.8rem;
        color: var(--color-text-dim);
        opacity: 1;
    }
    .progress-marker.active .marker-label {
        color: var(--color-marker-active);
        font-weight: 600;
    }

    /* --- Navigation Arrows: inside model-area, vertically centered --- */
    .nav-arrow {
        position: absolute;
        /* 프로그레스 바 영역 제외한 중앙 */
        top: calc(50% - 40px);
    }
    .nav-arrow-left {
        left: 1rem;
    }
    .nav-arrow-right {
        right: 1rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .sui-loading,
    .controls-hint,
    .accessibility-controls,
    .quiz-container {
        display: none;
    }
}
