/* CSS 변수 정의 - 다크 테마 (기본값) */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --accent-primary: #4a9eff;
    --accent-secondary: #6b73ff;
    --accent-danger: #ff4757;
    --accent-success: #2ed573;
    --accent-warning: #ffa502;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* 라이트 테마 */
:root[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #e9ecef;
    --bg-tertiary: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --accent-primary: #0d6efd;
    --accent-secondary: #6610f2;
    --accent-danger: #dc3545;
    --accent-success: #198754;
    --accent-warning: #fd7e14;
    --border-color: #ced4da;
    --shadow-color: rgba(0, 0, 0, 0.15);
}

/* 테마 전환 애니메이션 */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* 기본 리셋 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 접근성 - 스크린 리더 전용 텍스트 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

html {
    overflow-x: hidden;
}

/* 게임 컨테이너 */
.game-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 로딩 스크린 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

/* 시작 화면 */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.start-content {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
}

.game-title {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: 0.2em;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.3);
    position: relative;
    animation: glitchTitle 3s ease-in-out infinite;
}

.game-title::before,
.game-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.game-title::before {
    color: #666666;
    animation: glitchBefore 3s ease-in-out infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.game-title::after {
    color: #999999;
    animation: glitchAfter 3s ease-in-out infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

/* 시작 화면용 깔끔한 제목 (글리치 효과 없음) */
.game-title-clean {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: 0.2em;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.3);
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    line-height: 1.6;
}

.start-btn {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 1.2rem 3rem;
    font-size: 1.2rem;
    font-weight: 500;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(74, 158, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(74, 158, 255, 0.4);
    background: linear-gradient(45deg, var(--accent-secondary), var(--accent-primary));
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 글리치 효과 애니메이션 */
@keyframes glitchTitle {

    0%,
    90%,
    100% {
        transform: translate(0);
    }

    10% {
        transform: translate(-2px, 2px);
    }

    20% {
        transform: translate(2px, -2px);
    }

    30% {
        transform: translate(-2px, -2px);
    }

    40% {
        transform: translate(2px, 2px);
    }

    50% {
        transform: translate(-2px, 2px);
    }

    60% {
        transform: translate(2px, -2px);
    }
}

@keyframes glitchBefore {

    0%,
    90%,
    100% {
        opacity: 0;
        transform: translate(0);
    }

    10% {
        opacity: 0.8;
        transform: translate(-3px, 1px);
    }

    20% {
        opacity: 0;
    }

    30% {
        opacity: 0.6;
        transform: translate(2px, -1px);
    }

    40% {
        opacity: 0;
    }

    50% {
        opacity: 0.7;
        transform: translate(-2px, 2px);
    }

    60% {
        opacity: 0;
    }
}

@keyframes glitchAfter {

    0%,
    90%,
    100% {
        opacity: 0;
        transform: translate(0);
    }

    15% {
        opacity: 0.6;
        transform: translate(2px, -2px);
    }

    25% {
        opacity: 0;
    }

    35% {
        opacity: 0.8;
        transform: translate(-3px, 1px);
    }

    45% {
        opacity: 0;
    }

    55% {
        opacity: 0.5;
        transform: translate(3px, -1px);
    }

    65% {
        opacity: 0;
    }
}

/* 메인 게임 인터페이스 */
.main-game {
    display: grid;
    grid-template-areas:
        "header header"
        "content sidebar";
    grid-template-columns: 1fr 350px;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* 헤더 */
.game-header {
    grid-area: header;
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    position: relative;
}

/* 헤더 컨트롤 */
.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-icon {
    font-size: 1.2rem;
}

.header-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.header-icon {
    font-size: 1.1rem;
}

/* 설정 모달 */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}

.settings-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .settings-modal-content {
        min-width: 320px;
        max-width: 95vw;
        max-height: 90vh;
        margin: 1rem;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* 모바일에서 헤더 패딩 최적화 */
@media (max-width: 768px) {
    .settings-modal-header {
        padding: 1rem;
    }
}

.settings-modal-header h2 {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.settings-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close-btn:hover {
    background: var(--accent-danger);
    color: white;
}

.settings-modal-body {
    padding: 1.5rem;
    max-height: 65vh;
    overflow-y: auto;
}

/* 모바일에서 패딩 최적화 */
@media (max-width: 768px) {
    .settings-modal-body {
        padding: 1rem;
        max-height: 75vh;
    }
}

/* 설정 행 레이아웃 (음악/테마) - 정확한 정렬을 위한 조정 */
.settings-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: flex-end;
}

.settings-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 120px;
}

.settings-group .settings-label {
    margin-bottom: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-group .settings-controls {
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-group .settings-label {
    margin-bottom: 0.5rem;
    text-align: center;
}

.settings-group .settings-controls {
    justify-content: center;
}

/* 테마 및 음악 토글 버튼 아이콘/텍스트 스타일 */
.settings-btn .theme-icon,
.settings-btn .music-icon {
    font-size: 1rem;
}

.settings-btn .theme-text,
.settings-btn .music-text {
    font-size: 0.85rem;
}

.settings-btn.theme-toggle,
.settings-btn.music-toggle,
.settings-btn.audio-toggle {
    /* 다른 설정 버튼들과 동일한 크기 사용 */
    gap: 0;
}

/* 모바일에서도 설정 행 좌우 정렬 유지 */
@media (max-width: 768px) {
    .settings-row {
        gap: 1rem;
        justify-content: center;
    }

    .settings-group {
        min-width: 90px;
    }

    .settings-group .settings-label {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
}

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

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

.settings-section {
    margin-bottom: 1rem;
    text-align: center;
}

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

/* 모바일에서 설정 섹션 간격 최적화 */
@media (max-width: 768px) {
    .settings-section {
        margin-bottom: 0.75rem;
    }
}

.settings-label {
    display: block;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-align: center;
}

.settings-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
}

/* 모바일에서 컨트롤 간격 최적화 */
@media (max-width: 768px) {
    .settings-controls {
        gap: 0.5rem;
    }
}

.settings-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 모바일에서 버튼 크기 최적화 */
@media (max-width: 768px) {
    .settings-btn {
        padding: 0.6rem 0.8rem;
        min-width: 44px;
        min-height: 44px;
        font-size: 0.85rem;
    }
}

.settings-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.settings-value {
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 3rem;
    text-align: center;
}

.reset-btn {
    background: var(--accent-danger);
    border: 1px solid var(--accent-danger);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    width: 100%;
}

.reset-btn:hover {
    background: #ff3742;
    border-color: #ff3742;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.audio-controls {
    display: flex;
    gap: 0.5rem;
}

.audio-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.audio-toggle:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.audio-toggle.muted {
    background: var(--bg-tertiary);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

.audio-toggle.muted:hover {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
    color: white;
}

/* 메인 콘텐츠 */
.game-content {
    grid-area: content;
    padding: 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 80px);
    width: 100%;
    min-width: 0;
}

.story-section {
    margin-bottom: 2rem;
}

.story-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-line;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.story-text p {
    margin-bottom: 1.5rem;
}

/* 퍼즐 섹션 */
.puzzle-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.puzzle-hint {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--accent-warning);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.puzzle-hint:empty {
    display: none;
}

.puzzle-input {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    align-items: stretch;
}

.answer-input {
    flex: 1;
    min-width: 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
    transform: translateY(-1px);
}

.submit-btn,
.next-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent-primary);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover,
.next-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.feedback-message {
    padding: 0.75rem;
    border-radius: 4px;
    font-weight: 500;
    text-align: center;
    display: none;
}

.feedback-message.success {
    background: rgba(46, 213, 115, 0.1);
    border: 1px solid var(--accent-success);
    color: var(--accent-success);
}

.feedback-message.error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
}

/* 네비게이션 섹션 */
.navigation-section {
    text-align: center;
}

/* 사이드바 */
.game-sidebar {
    grid-area: sidebar;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    width: 350px;
    min-width: 350px;
    overflow-x: hidden;
    height: calc(100vh - 80px);
    /* 헤더 높이 제외한 고정 높이 */
}

.control-panel {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toggle-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.info-panels {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* PC용 고정 입력 섹션 */
.sidebar-input-section.desktop-only {
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    background: var(--bg-tertiary);
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
    /* 크기 고정 */
    z-index: 10;
    /* 다른 요소 위에 표시 */
}

/* 모바일용 패널 내 입력 섹션 */
.panel .sidebar-input-container {
    margin-top: 1rem;
}

.panel .sidebar-feedback {
    margin-top: 0.75rem;
}

.sidebar-input-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.sidebar-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.sidebar-answer-input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.sidebar-answer-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.sidebar-submit-btn {
    padding: 0.75rem 1rem;
    background: var(--accent-primary);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.sidebar-submit-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.sidebar-feedback {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    display: none;
}

.sidebar-feedback.success {
    background: rgba(46, 213, 115, 0.1);
    border: 1px solid var(--accent-success);
    color: var(--accent-success);
}

.sidebar-feedback.error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--accent-danger);
    color: var(--accent-danger);
}

.panel {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: none;
}

.panel.active {
    display: block;
}

.panel h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.panel-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.empty-message {
    color: var(--text-muted);
    font-style: italic;
}

/* 반응형 디자인 */

/* 데스크톱 최적화 (1200px 이상) */
@media (min-width: 1200px) {
    .main-game {
        grid-template-columns: 1fr 400px;
    }

    .game-sidebar {
        width: 400px;
        min-width: 400px;
    }

    .game-content {
        padding: 2.5rem;
        max-width: none;
    }

    .story-text {
        font-size: 1.2rem;
        line-height: 1.9;
    }

    /* PC에서 모바일 패널 내 입력 숨기기 */
    .panel#inputPanel {
        display: none !important;
    }

    .toggle-btn[data-target="input"] {
        display: none !important;
    }
}

/* 태블릿 최적화 (768px - 1199px) */
@media (min-width: 769px) and (max-width: 1199px) {
    .main-game {
        grid-template-columns: 1fr 280px;
    }

    .game-sidebar {
        width: 280px;
        min-width: 280px;
    }

    .game-content {
        padding: 1.5rem;
    }

    .toggle-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* 터치 인터페이스 최적화 */
    .sidebar-submit-btn,
    .audio-toggle,
    .toggle-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .sidebar-answer-input {
        min-height: 44px;
        font-size: 1rem;
    }

    /* PC에서 모바일 패널 내 입력 숨기기 */
    .panel#inputPanel {
        display: none !important;
    }

    .toggle-btn[data-target="input"] {
        display: none !important;
    }
}

/* 태블릿 세로 모드 및 작은 화면 (768px 이하) */
@media (max-width: 768px) {
    .main-game {
        grid-template-areas:
            "header"
            "content"
            "sidebar";
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: 100vh;
        overflow: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .game-header {
        padding: 0.5rem 1rem;
        min-height: 50px;
    }

    .page-title {
        flex: 1;
        text-align: left;
        font-size: 1.1rem;
        min-width: 0;
    }

    .header-controls {
        gap: 0.25rem;
    }

    .nav-btn,
    .header-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 0.25rem;
    }

    .nav-icon,
    .header-icon {
        font-size: 1rem;
    }

    .game-content {
        padding: 0.75rem;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        min-width: 0;
        height: 100%;
        padding-bottom: 0;
        /* 하단 여백 제거 */
    }

    .story-section {
        margin-bottom: 0.5rem;
    }

    .story-text {
        font-size: 0.9rem;
        line-height: 1.5;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* 접이식 사이드바 - 기본 상태에서는 탭만 보임 */
    .game-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        height: 44px;
        /* 기본 높이: 탭만 */
        overflow: hidden;
        display: flex;
        flex-direction: column;
        transition: height 0.3s ease;
        z-index: 100;
        margin: 0;
        padding: 0;
    }

    .game-sidebar.expanded {
        height: 200px;
        /* 확장 시 높이 */
    }

    .control-panel {
        flex-direction: row;
        padding: 0;
        margin: 0;
        gap: 0;
        overflow: hidden;
        flex-shrink: 0;
        height: 44px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        width: 100vw;
        display: flex;
        box-sizing: border-box;
    }

    .toggle-btn {
        flex: 1;
        justify-content: center;
        align-items: center;
        min-height: 44px;
        font-size: 0.7rem;
        padding: 0;
        margin: 0;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        border-right: 1px solid var(--border-color);
    }

    .toggle-btn:last-child {
        border-right: none;
    }

    .toggle-btn .label {
        display: none;
    }

    .toggle-btn .icon {
        font-size: 1rem;
    }

    .info-panels {
        flex: 1;
        overflow: hidden;
        min-height: 0;
        max-height: 160px;
        background: var(--bg-secondary);
        width: 100vw;
        box-sizing: border-box;
    }

    .panel {
        padding: 0.5rem;
        font-size: 0.8rem;
        display: none;
        height: 160px;
        overflow: hidden;
    }

    .panel.scrollable {
        overflow-y: auto;
    }

    .panel.active {
        display: block;
        animation: slideUp 0.3s ease;
    }

    .panel h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .panel-content {
        font-size: 0.75rem;
        line-height: 1.3;
        max-height: 120px;
        overflow: hidden;
    }

    .panel-content.scrollable {
        overflow-y: auto;
    }

    /* 모바일에서 PC용 입력 섹션 숨기기 */
    .sidebar-input-section.desktop-only {
        display: none !important;
    }

    /* 모바일 패널 내 입력 스타일 */
    .panel .sidebar-input-container {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .panel .sidebar-submit-btn {
        width: 100%;
        min-height: 36px;
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .panel .sidebar-answer-input {
        min-height: 36px;
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .panel .sidebar-feedback {
        margin-top: 0.3rem;
        padding: 0.3rem;
        font-size: 0.7rem;
    }
}

/* 모바일 최적화 (480px 이하) */
@media (max-width: 480px) {
    .main-game {
        height: 100vh;
        grid-template-rows: auto 1fr 0;
        /* 사이드바 공간 제거 */
    }

    .game-header {
        padding: 0.4rem 0.75rem;
        min-height: 45px;
        overflow-x: hidden;
    }

    .page-title {
        font-size: 0.9rem;
        flex: 1;
        min-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .audio-controls {
        flex-shrink: 0;
    }

    .audio-toggle {
        padding: 0.3rem;
        font-size: 0.8rem;
    }

    .game-title {
        font-size: 1.8rem;
        letter-spacing: 0.1em;
    }

    .game-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1.2rem;
    }

    .start-btn {
        padding: 0.9rem 1.8rem;
        font-size: 0.95rem;
        width: 75%;
        max-width: 250px;
    }

    .game-content {
        padding: 0.5rem;
        padding-bottom: 50px;
        /* 하단 탭 공간 확보 */
        overflow-y: auto;
        overflow-x: hidden;
        height: 100%;
    }

    .story-section {
        margin-bottom: 0.3rem;
    }

    .story-text {
        font-size: 0.8rem;
        line-height: 1.4;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .game-sidebar {
        height: 36px;
        /* 기본 높이 더 작게 */
        width: 100vw;
    }

    .game-sidebar.expanded {
        height: 180px;
        /* 확장 높이 */
    }

    .control-panel {
        padding: 0;
        margin: 0;
        gap: 0;
        height: 36px;
        width: 100vw;
    }

    .toggle-btn {
        min-height: 36px;
        font-size: 0.6rem;
        padding: 0;
        margin: 0;
    }

    .toggle-btn .icon {
        font-size: 0.85rem;
    }

    .panel {
        padding: 0.4rem;
        height: 144px;
        /* 확장 높이에서 탭 높이 제외 */
    }

    .panel h3 {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
    }

    .panel-content {
        font-size: 0.7rem;
        line-height: 1.2;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-height: 100px;
    }

    .panel .sidebar-input-container {
        gap: 0.3rem;
    }

    .panel .sidebar-answer-input {
        min-height: 32px;
        font-size: 0.75rem;
        padding: 0.4rem;
    }

    .panel .sidebar-submit-btn {
        min-height: 32px;
        font-size: 0.75rem;
        padding: 0.4rem;
    }

    .panel .sidebar-feedback {
        margin-top: 0.2rem;
        padding: 0.2rem;
        font-size: 0.65rem;
    }
}

/* 게임 엔딩 모달 스타일 */
.game-ending-modal .ending-modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.ending-header h2 {
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.ending-message {
    margin: 1.5rem 0;
    color: var(--text-primary);
    line-height: 1.6;
}

.ending-credits {
    margin: 2rem 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-secondary);
}

.ending-credits h3 {
    color: var(--accent-secondary);
    margin-bottom: 1rem;
}

.ending-credits p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

.ending-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.ending-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.ending-btn.primary {
    background: var(--accent-primary);
    color: white;
}

.ending-btn.primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

.ending-btn.supporters {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
    font-weight: 600;
}

.ending-btn.supporters:hover {
    background: linear-gradient(45deg, #ffed4e, #ffd700);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.ending-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.ending-btn.secondary:hover {
    background: var(--accent-danger);
    color: white;
    transform: translateY(-2px);
}

/* 후원자 명단 모달 스타일 */
.supporters-modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.supporters-header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.supporters-back-btn {
    position: absolute;
    left: 0;
    top: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.supporters-back-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.supporters-header h2 {
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    font-size: 1.6rem;
}

.supporters-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.supporters-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.supporters-tab {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 140px;
    justify-content: center;
}

.supporters-tab:hover {
    background: var(--accent-primary);
    color: white;
}

.supporters-tab.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.supporters-tab[data-tab="keyWitnesses"].active {
    background: linear-gradient(45deg, #9d4edd, #c77dff);
}

.supporters-tab[data-tab="firstWitnesses"].active {
    background: linear-gradient(45deg, #ffd60a, #ffbe0b);
}

.supporters-tab[data-tab="recordReaders"].active {
    background: linear-gradient(45deg, #4cc9f0, #7209b7);
}

.tab-icon {
    font-size: 1.1rem;
}

.tab-label {
    font-weight: 500;
}

.supporters-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.supporters-list {
    display: none;
}

.supporters-list.active {
    display: block;
}

.supporters-list h3 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.list-icon {
    font-size: 1.2rem;
}

.supporters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.8rem;
    padding: 1rem 0;
}

.supporter-name {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.supporter-name:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.supporter-name.key {
    border-left: 4px solid #9d4edd;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(157, 78, 221, 0.1));
}

.supporter-name.key:hover {
    border-left-color: #c77dff;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(199, 125, 255, 0.2));
}

.supporter-name.first {
    border-left: 4px solid #ffd60a;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(255, 214, 10, 0.1));
}

.supporter-name.first:hover {
    border-left-color: #ffbe0b;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(255, 190, 11, 0.2));
}

.supporter-name.reader {
    border-left: 4px solid #4cc9f0;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(76, 201, 240, 0.1));
}

.supporter-name.reader:hover {
    border-left-color: #7209b7;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(114, 9, 183, 0.2));
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .supporters-modal-content {
        padding: 1rem;
        max-height: 90vh;
    }

    .supporters-header h2 {
        font-size: 1.3rem;
        margin-top: 2rem;
    }

    .supporters-tabs {
        flex-direction: column;
        gap: 0.3rem;
    }

    .supporters-tab {
        min-width: auto;
        padding: 0.6rem 1rem;
    }

    .supporters-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .supporter-name {
        padding: 0.5rem 0.6rem;
        font-size: 0.9rem;
    }

    .supporters-back-btn {
        position: static;
        margin-bottom: 1rem;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .supporters-grid {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 0.4rem;
    }

    .supporter-name {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }

    .ending-buttons {
        flex-direction: column;
        align-items: center;
    }

    .ending-btn {
        width: 100%;
        max-width: 200px;
    }
}

/* 매우 작은 화면 (320px 이하) */
@media (max-width: 320px) {
    .main-game {
        height: 100vh;
        grid-template-rows: auto 1fr 0;
        /* 사이드바 공간 제거 */
    }

    .game-header {
        padding: 0.3rem 0.5rem;
        min-height: 40px;
    }

    .page-title {
        font-size: 0.8rem;
    }

    .audio-toggle {
        padding: 0.25rem;
        font-size: 0.7rem;
    }

    .game-title {
        font-size: 1.5rem;
    }

    .game-content {
        padding: 0.4rem;
        padding-bottom: 40px;
        /* 하단 탭 공간 확보 */
        height: 100%;
        overflow-y: auto;
    }

    .story-text {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .game-sidebar {
        height: 32px;
        /* 기본 높이 더 작게 */
        width: 100vw;
    }

    .game-sidebar.expanded {
        height: 160px;
        /* 확장 높이 */
    }

    .control-panel {
        padding: 0;
        margin: 0;
        gap: 0;
        height: 32px;
        width: 100vw;
    }

    .toggle-btn {
        min-height: 32px;
        font-size: 0.55rem;
        padding: 0;
        margin: 0;
    }

    .toggle-btn .icon {
        font-size: 0.75rem;
    }

    .panel {
        padding: 0.3rem;
        height: 128px;
        /* 확장 높이에서 탭 높이 제외 */
    }

    .panel h3 {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .panel-content {
        font-size: 0.65rem;
        line-height: 1.1;
        max-height: 90px;
    }

    .panel .sidebar-input-container {
        gap: 0.25rem;
    }

    .panel .sidebar-answer-input {
        min-height: 28px;
        font-size: 0.7rem;
        padding: 0.3rem;
    }

    .panel .sidebar-submit-btn {
        min-height: 28px;
        font-size: 0.7rem;
        padding: 0.3rem;
    }

    .panel .sidebar-feedback {
        margin-top: 0.15rem;
        padding: 0.15rem;
        font-size: 0.6rem;
    }
}

/* 애니메이션 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* 페이지 전환 애니메이션 */
.page-transition-out {
    animation: pageTransitionOut 0.3s ease-in forwards;
}

.page-transition-in {
    animation: pageTransitionIn 0.4s ease-out forwards;
}

@keyframes pageTransitionOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

@keyframes pageTransitionIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 스토리 텍스트 타이핑 효과 */
.typing-effect {
    overflow: hidden;
    border-right: 2px solid var(--accent-primary);
    animation: typing-cursor 1s infinite;
}

@keyframes typing-cursor {

    0%,
    50% {
        border-color: var(--accent-primary);
    }

    51%,
    100% {
        border-color: transparent;
    }
}

/* 퍼즐 섹션 등장 애니메이션 */
.puzzle-appear {
    animation: puzzleAppear 0.6s ease-out forwards;
}

@keyframes puzzleAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 사이드바 패널 전환 애니메이션 */
.panel-slide-in {
    animation: panelSlideIn 0.3s ease-out forwards;
}

.panel-slide-out {
    animation: panelSlideOut 0.2s ease-in forwards;
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

@keyframes panelSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* 스크롤바 스타일링 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* 접근성 및 포커스 스타일 */
.submit-btn:focus,
.next-btn:focus,
.audio-toggle:focus,
.toggle-btn:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.answer-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* 버튼 비활성화 상태 */
.submit-btn:disabled,
.next-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.submit-btn:disabled:hover,
.next-btn:disabled:hover {
    background: var(--bg-tertiary);
    transform: none;
}

/* 로딩 상태 */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 게임 상태별 스타일 */
.game-container.game-completed .game-content {
    text-align: center;
}

.game-container.game-completed .story-text {
    font-size: 1.3rem;
    color: var(--accent-success);
}

/* 퍼즐 박스 스타일 */
.puzzle-box {
    border: 2px solid var(--accent-primary);
    background: rgba(74, 158, 255, 0.1);
    padding: 1.5rem 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    position: relative;
}

.puzzle-box::before {
    content: "🔑 KEY";
    position: absolute;
    top: -10px;
    left: 1rem;
    background: var(--bg-primary);
    color: var(--accent-primary);
    padding: 2px 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

/* 향상된 시각적 피드백 */
.panel-content .memory-fragment {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: 4px;
    border-left: 3px solid var(--accent-primary);
}

.panel-content .clue-fragment {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: 4px;
    border-left: 3px solid var(--accent-primary);
}

/* 힌트 아코디언 스타일 */
.hint-accordion {
    margin: 0.25rem 0;
}

.hint-accordion-item {
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-primary);
    margin-bottom: 0.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.hint-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    cursor: pointer;
    background: var(--bg-tertiary);
    border: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.hint-accordion-header:hover {
    background: var(--bg-primary);
}

.hint-accordion-header.active {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.hint-accordion-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hint-accordion-icon {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.hint-accordion-header.active .hint-accordion-icon {
    transform: rotate(90deg);
}

.hint-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.hint-accordion-content.active {
    max-height: 200px;
}

.hint-accordion-body {
    padding: 0.75rem;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
    border-top: 1px solid var(--border-color);
}

.hint-status {
    font-size: 0.7rem;
    color: var(--accent-success);
    font-weight: 500;
}

/* 모바일에서 힌트 아코디언 조정 */
@media (max-width: 768px) {
    .hint-accordion-header {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .hint-accordion-body {
        padding: 0.5rem;
        font-size: 0.7rem;
    }

    .hint-accordion-content.active {
        max-height: 150px;
    }
}

/* 동적 레이아웃 조정을 위한 컨테이너 쿼리 지원 */
@container (max-width: 600px) {
    .puzzle-input {
        flex-direction: column;
    }
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --bg-tertiary: #333333;
        --text-primary: #ffffff;
        --border-color: #666666;
        --accent-primary: #66b3ff;
    }
}

/* 애니메이션 감소 설정 존중 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner {
        animation: none;
        border: 3px solid var(--accent-primary);
    }
}

/* 숨겨진 메모를 담는 span 태그 스타일 */
.hidden-memo-trigger {
    display: block;  /* span이지만 div처럼 한 줄을 모두 차지하게 만듭니다. */
    margin-top: 20px; /* 교사 명단과의 상단 간격을 충분히 줍니다. */
    padding: 2px 4px; /* 💥 핵심: 패딩을 최소화하여 텍스트 크기에 딱 맞게 만듭니다. */
    background-color: transparent; /* 평소에는 배경색이 없도록 합니다. */
    cursor: text;
}

/* 실제로 숨겨진 텍스트 */
.hidden-text {
    color: transparent; /* 💥 핵심: 글자색을 투명하게 만듭니다. */
}

/* 💥 마법이 일어나는 부분: 숨겨진 메모가 선택(::selection)될 때 */
.hidden-memo-trigger::selection {
    color: #eeeeee;            /* 글자색을 보이게 합니다. */
    background-color: transparent; /* 드래그 시 배경 하이라이트는 없앱니다. */
}

/* 마우스를 올릴 단어('해답')와 그 주변을 위한 기본 설정 */
.tooltip-trigger {
    position: relative; /* 이 요소가 기준점이 됩니다. */
  }
  
  /* 정답 박스의 평소 모습 (숨겨진 상태) */
  .tooltip-content {
    visibility: hidden; /* 💥 핵심: 평소에는 보이지 않게 숨깁니다. */
    opacity: 0;         /* 투명하게 만듭니다. (부드러운 효과를 위해) */
  
    /* ----- 아래는 박스 디자인 ----- */
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    
    /* 위치 설정 */
    position: absolute;
    z-index: 1;
    bottom: 150%; /* '해답' 단어 바로 위에 뜨도록 */
    left: 50%;
    margin-left: -60px; /* 너비의 절반만큼 왼쪽으로 이동시켜 중앙 정렬 */
    
    /* 부드러운 효과 */
    transition: opacity 0.3s;
  }
  
  /* 💥 마법이 일어나는 부분 💥 */
  /* PC: '해답' 단어에 마우스를 올렸을 때(hover), 숨겨진 박스가 보이도록 변경 */
  .tooltip-trigger:hover .tooltip-content {
    visibility: visible; /* ✨ 핵심: 보이게 만듭니다. */
    opacity: 1;
  }

  /* 모바일: 터치했을 때 tooltip 표시 (JavaScript로 제어) */
  .tooltip-trigger.active .tooltip-content {
    visibility: visible;
    opacity: 1;
  }

  /* 모바일 최적화: 터치 영역 확대 */
  @media (max-width: 768px) {
    .tooltip-trigger {
      padding: 0.2rem;
      margin: -0.2rem;
      border-radius: 4px;
      background: rgba(74, 158, 255, 0.1);
      border: 1px dashed var(--accent-primary);
    }

    .tooltip-content {
      width: 100px;
      font-size: 0.8rem;
      padding: 0.3rem;
      margin-left: -50px;
      bottom: 120%;
    }
  }
/* 게임 엔딩 모달 스타일 */
.game-ending-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.5s ease-out;
}

.ending-modal-content {
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

.ending-header h2 {
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.ending-message {
    margin: 1.5rem 0;
    line-height: 1.6;
}

.ending-message p {
    margin: 0.5rem 0;
    color: var(--text-primary);
    font-style: italic;
}

.ending-credits {
    margin: 2rem 0;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.ending-credits h3 {
    color: var(--accent-primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.ending-credits p {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.ending-buttons {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.ending-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.ending-btn.primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.ending-btn.primary:hover {
    background: #4a9eff;
    transform: translateY(-2px);
}

.ending-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.ending-btn.secondary:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

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

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .ending-modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .ending-header h2 {
        font-size: 1.5rem;
    }
    
    .ending-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .ending-btn {
        width: 100%;
        max-width: 200px;
    }
}/* 게임 
소개 페이지 스타일 */
.intro-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    line-height: 1.4;
}

.intro-content h2 {
    color: var(--accent-primary);
    margin: 1rem 0 0.5rem 0;
    font-size: 1.2rem;
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 0.3rem;
}

.intro-content p {
    margin: 0.4rem 0;
    color: var(--text-primary);
}

.intro-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.intro-content li {
    margin: 0.2rem 0;
    color: var(--text-primary);
}

.intro-content li strong {
    color: var(--text-primary);
}

.intro-buttons {
    text-align: center;
    margin: 1.5rem 0 0.5rem 0;
}

.intro-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
}

.intro-btn.primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.intro-btn.primary:hover {
    background: #4a9eff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .intro-content {
        padding: 1rem;
    }
    
    .intro-content h2 {
        font-size: 1.1rem;
    }
    
    .intro-btn {
        width: 100%;
        max-width: 280px;
    }
}/*
 코드 입력 모달 스타일 */
.code-modal-content {
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: slideIn 0.5s ease-out;
    position: relative;
}

.code-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.code-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.1);
}

.code-header h2 {
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.code-message {
    margin: 1.5rem 0;
    line-height: 1.6;
}

.code-message p {
    margin: 0.5rem 0;
    color: var(--text-primary);
}

.code-input-section {
    margin-top: 2rem;
}

.code-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    margin-bottom: 1rem;
}

.code-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.code-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.code-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.code-btn.primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.code-btn.primary:hover {
    background: #4a9eff;
    transform: translateY(-2px);
}

.code-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.code-btn.secondary:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

.code-error {
    color: #ff4d4d;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .code-modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .code-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .code-btn {
        width: 100%;
        max-width: 200px;
    }
}