/**
 * ============================================================================
 * style.css - Nevergrad 기본 스타일
 * ============================================================================
 * CSS Custom Properties로 테마 전환 (romance → thriller)
 */

/* ===== Theme Variables ===== */
:root {
    --color-primary: #FFB7C5;
    --color-secondary: #FFF0F5;
    --color-text: #4A3040;
    --color-dialogue-bg: rgba(255, 240, 245, 0.92);
    --color-accent: #FF69B4;

    --transition-theme: all 2s ease;
    --font-main: 'Noto Sans KR', sans-serif;
}

/* ===== Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background: #000;
    color: var(--color-text);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== Screen System ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

.screen.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.overlay {
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
}

/* ===== Title Screen ===== */
#title-screen {
    background: #0a0008;
    transition: var(--transition-theme);
    overflow: hidden;
}

.title-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../images/background/title_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* 이미지 위에 어두운 오버레이를 얹어 텍스트 가독성 확보 */
    filter: brightness(0.45) saturate(0.8);
    animation: title-bg-breathe 8s ease-in-out infinite;
}

/* 타이틀 이미지 미로드 시 CSS 그라디언트 폴백 */
.title-bg-layer.no-image {
    background-image: none;
    filter: none;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 183, 197, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(180, 130, 200, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 105, 180, 0.08) 0%, transparent 70%),
        linear-gradient(180deg, #0f0010 0%, #1a0520 30%, #0d0018 70%, #050008 100%);
}

@keyframes title-bg-breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.title-bg-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
}

.title-content {
    text-align: center;
    position: relative;
    z-index: 2;
    animation: title-fade-in 2s ease forwards;
}

@keyframes title-fade-in {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.title-text {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    margin-bottom: 0.8rem;
    background: linear-gradient(180deg, #fff 0%, #FFB7C5 40%, #FF69B4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(255, 105, 180, 0.4)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    transition: var(--transition-theme);
}

.title-divider {
    width: 120px;
    height: 1px;
    margin: 0 auto 0.8rem;
    background: linear-gradient(90deg, transparent, rgba(255, 183, 197, 0.6), transparent);
    animation: divider-glow 3s ease-in-out infinite;
}

@keyframes divider-glow {
    0%, 100% { opacity: 0.5; width: 120px; }
    50% { opacity: 1; width: 160px; }
}

.title-subtitle {
    font-size: 1rem;
    font-weight: 300;
    color: rgba(255, 183, 197, 0.7);
    letter-spacing: 0.5em;
    transition: var(--transition-theme);
    animation: subtitle-fade 2.5s ease forwards;
}

@keyframes subtitle-fade {
    0% { opacity: 0; letter-spacing: 1em; }
    100% { opacity: 1; letter-spacing: 0.5em; }
}

.title-menu {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    position: relative;
    z-index: 2;
    animation: title-fade-in 2.5s ease forwards;
}

.menu-btn {
    background: rgba(255, 183, 197, 0.15);
    color: rgba(255, 240, 245, 0.9);
    border: 1px solid rgba(255, 183, 197, 0.3);
    padding: 0.8rem 3rem;
    font-size: 1rem;
    font-family: var(--font-main);
    border-radius: 0.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.15em;
    white-space: nowrap;
    min-width: 200px;
    backdrop-filter: blur(4px);
}

.menu-btn:hover {
    background: rgba(255, 183, 197, 0.3);
    border-color: rgba(255, 183, 197, 0.6);
    transform: none;
    box-shadow: 0 0 20px rgba(255, 105, 180, 0.2);
    color: #fff;
}

.menu-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    filter: grayscale(1);
    pointer-events: none;
    border-color: rgba(255, 183, 197, 0.1);
}

.title-footer {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 2;
}

.title-copyright {
    font-size: 0.7rem;
    color: rgba(255, 183, 197, 0.25);
    letter-spacing: 0.3em;
    font-weight: 300;
}

/* ===== Name Input ===== */
#name-screen {
    background: #0a0008;
}

.name-input-container {
    text-align: center;
    background: linear-gradient(180deg, rgba(30, 15, 25, 0.9), rgba(20, 10, 20, 0.95));
    border: 1px solid rgba(255, 183, 197, 0.15);
    padding: 3rem;
    border-radius: 0.5rem;
    backdrop-filter: blur(10px);
}

.name-prompt {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: rgba(255, 240, 245, 0.85);
    letter-spacing: 0.1em;
}

#player-name-input {
    font-family: var(--font-main);
    font-size: 1.2rem;
    padding: 0.8rem 1.5rem;
    border: 1px solid rgba(255, 183, 197, 0.3);
    border-radius: 0.3rem;
    outline: none;
    text-align: center;
    width: 200px;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.3s;
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 240, 245, 0.9);
}

#player-name-input::placeholder {
    color: rgba(255, 183, 197, 0.3);
}

#player-name-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.15);
}

/* ===== Game Screen ===== */
#game-screen {
    background: #000;
}

/* Background */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
    transition: filter 1s ease;
}

/* 배경 크로스페이드용 오버레이 */
.bg-layer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--bg-next);
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    pointer-events: none;
}
.bg-layer.bg-crossfade::after {
    opacity: 1;
}

.bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    transition: background 1s ease;
}

/* Time-of-day overlays */
.bg-overlay.morning {
    background: linear-gradient(180deg, rgba(255, 240, 200, 0.08) 0%, rgba(255, 220, 180, 0.12) 100%);
}

.bg-overlay.sunset {
    background: linear-gradient(180deg, rgba(255, 120, 50, 0.2) 0%, rgba(255, 60, 20, 0.35) 100%);
}

.bg-overlay.night {
    background: linear-gradient(180deg, rgba(10, 10, 40, 0.5) 0%, rgba(5, 5, 30, 0.65) 100%);
}

.bg-overlay.dawn {
    background: linear-gradient(180deg, rgba(80, 60, 120, 0.3) 0%, rgba(180, 100, 80, 0.2) 100%);
}

.bg-overlay.rain {
    background: linear-gradient(180deg, rgba(30, 30, 50, 0.5) 0%, rgba(20, 20, 40, 0.6) 100%);
}

.bg-overlay.dark {
    background: linear-gradient(180deg, rgba(5, 5, 15, 0.6) 0%, rgba(0, 5, 10, 0.75) 100%);
}

/* bg-layer CSS filters for time-of-day */
.bg-layer.time-morning {
    filter: brightness(1.05) saturate(1.05);
}

.bg-layer.time-sunset {
    filter: brightness(0.85) saturate(1.2) sepia(0.15) hue-rotate(-10deg);
}

.bg-layer.time-night {
    filter: brightness(0.35) saturate(0.5) hue-rotate(10deg);
}

.bg-layer.time-dawn {
    filter: brightness(0.55) saturate(0.7) hue-rotate(-5deg);
}

.bg-layer.time-dark {
    filter: brightness(0.2) saturate(0.3) hue-rotate(15deg);
}

.bg-layer.time-rain {
    filter: brightness(0.6) saturate(0.6) contrast(1.1);
}

/* Characters */
.char-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.character-sprite {
    position: absolute;
    bottom: 0;
    height: 90%;
    object-fit: contain;
    transition: opacity 0.25s ease-in-out, transform 0.3s ease, filter 0.3s ease;
    will-change: opacity;
}

.character-sprite[src=""] {
    opacity: 0;
    pointer-events: none;
}

.pos-left { left: 5%; }
.pos-center { left: 50%; transform: translateX(-50%); --char-offset-x: -50%; }
.pos-right { right: 5%; }

.char-talking {
    /* breathing 제거 — 투명 대화창에서 글자 가독성 저해 */
}

@keyframes char-breathe {
    0%, 100% { transform: translateX(var(--char-offset-x, 0)) translateY(0); }
    50% { transform: translateX(var(--char-offset-x, 0)) translateY(-3px); }
}

/* 캐릭터 페이드 인/아웃 */
.character-sprite.char-fade-in {
    opacity: 0;
}
.character-sprite.char-fade-out {
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}

/* 같은 캐릭터 표정 크로스페이드 */
.character-sprite.char-crossfade-in {
    opacity: 0;
}
.char-crossfade-out {
    position: absolute;
    bottom: 0;
    height: 90%;
    object-fit: contain;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
    will-change: opacity;
}

/* ===== Dialogue Box ===== */
.dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem 1.5rem 1.5rem;
    background: linear-gradient(180deg,
        rgba(20, 12, 40, 0.25) 0%,
        rgba(12, 6, 35, 0.55) 100%
    );
    border-top: 1px solid rgba(255, 183, 197, 0.25);
    z-index: 10;
    min-height: 150px;
    cursor: pointer;
    transition: background 2s ease, border-color 2s ease;
    backdrop-filter: none;
}

.speaker-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-primary);
    margin-bottom: 0.4rem;
    padding: 0.15rem 0.8rem;
    background: rgba(255, 183, 197, 0.08);
    border-left: 2px solid var(--color-accent);
    display: inline-block;
    border-radius: 0 0.2rem 0.2rem 0;
    transition: color 2s ease, background 2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.5);
}

.dialogue-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: rgba(255, 240, 245, 0.95);
    min-height: 3em;
    transition: color 2s ease;
    padding-top: 0.3rem;
    text-shadow: 0 0 3px rgba(0, 0, 0, 1), 0 0 6px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(0, 0, 0, 1), 0 0 12px rgba(0, 0, 0, 0.5);
}

.click-indicator {
    position: absolute;
    bottom: 0.8rem;
    right: 1.2rem;
    font-size: 0.8rem;
    color: var(--color-primary);
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(4px); opacity: 0.5; }
}

/* Narration (asterisk-wrapped text) */
.narration {
    font-style: italic;
    color: rgba(255, 220, 230, 0.95);
    text-align: left;
    letter-spacing: 0.02em;
    padding: 0.4rem 1.2rem;
    text-shadow: 0 0 3px rgba(0, 0, 0, 1), 0 0 6px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(0, 0, 0, 1), 0 0 12px rgba(0, 0, 0, 0.5);
}

.speaker-name.hidden {
    visibility: hidden;
}

/* ===== Choice Panel ===== */
.choice-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: rgba(0, 0, 0, 0.35);
    padding: 1rem;
}

.choice-btn {
    background: rgba(20, 10, 20, 0.5);
    color: rgba(255, 240, 245, 0.95);
    border: 1px solid rgba(255, 183, 197, 0.3);
    padding: 0.8rem 2rem;
    font-size: 0.95rem;
    font-family: var(--font-main);
    border-radius: 0.3rem;
    cursor: pointer;
    width: 80%;
    max-width: 500px;
    text-align: center;
    transition: all 0.3s ease;
    word-break: keep-all;
    overflow-wrap: break-word;
    backdrop-filter: blur(10px);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    /* i18n: 긴 텍스트(de/fr) 대비 최소 높이 보장 + 줄바꿈 허용 */
    min-height: 2.6rem;
    line-height: 1.4;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.choice-btn:hover {
    background: rgba(255, 183, 197, 0.2);
    color: #fff;
    border-color: rgba(255, 183, 197, 0.6);
    transform: none;
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.15);
}

/* ===== HUD ===== */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0.6rem 1rem;
    z-index: 15;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
}

.day-display {
    font-size: 0.8rem;
    color: rgba(255, 240, 245, 0.8);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.1em;
    white-space: nowrap;
    overflow: hidden;
    max-width: 65%;
    text-overflow: ellipsis;
    padding: 0.2rem 0.6rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.2rem;
}

.stat-display {
    font-size: 0.8rem;
    color: var(--color-primary);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
    padding: 0.2rem 0.6rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.2rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
    transition: color 0.3s ease, opacity 0.4s ease, transform 0.4s ease;
}

.stat-display.stat-hidden {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
}

.stat-display.stat-bump {
    animation: stat-bump-anim 0.35s ease;
}

@keyframes stat-bump-anim {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); color: #fff; }
    100% { transform: scale(1); }
}

/* ===== 진동 시각 효과 (PC에서도 진동 느낌) ===== */
.vfx-buzz { animation: vfx-buzz-anim 0.2s ease; }
@keyframes vfx-buzz-anim {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(2px); }
    50% { transform: translateX(-2px); }
    75% { transform: translateX(1px); }
}

.vfx-shake { animation: vfx-shake-anim 0.4s ease; }
@keyframes vfx-shake-anim {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-3px, 1px); }
    30% { transform: translate(3px, -2px); }
    50% { transform: translate(-2px, 2px); }
    70% { transform: translate(2px, -1px); }
    90% { transform: translate(-1px, 1px); }
}

.vfx-shake-heavy { animation: vfx-shake-heavy-anim 0.8s ease; }
@keyframes vfx-shake-heavy-anim {
    0%, 100% { transform: translate(0, 0); filter: none; }
    5% { transform: translate(-5px, 3px); }
    15% { transform: translate(6px, -4px); filter: brightness(1.1); }
    25% { transform: translate(-4px, 2px); }
    35% { transform: translate(5px, -3px); filter: brightness(0.9); }
    55% { transform: translate(4px, -2px); }
    75% { transform: translate(3px, -1px); }
    85% { transform: translate(-1px, 1px); }
}

.vfx-pulse { animation: vfx-pulse-anim 1s ease; }
@keyframes vfx-pulse-anim {
    0%, 100% { filter: none; }
    15% { filter: brightness(0.85) saturate(1.3); }
    30% { filter: none; }
    50% { filter: brightness(0.85) saturate(1.3); }
    65% { filter: none; }
    80% { filter: brightness(0.9) saturate(1.1); }
}

.vfx-impact { animation: vfx-impact-anim 0.3s ease; }
@keyframes vfx-impact-anim {
    0% { transform: scale(1); filter: none; }
    30% { transform: scale(1.02); filter: brightness(1.5) contrast(1.2); }
    60% { transform: scale(0.99); filter: brightness(0.7); }
    100% { transform: scale(1); filter: none; }
}

.vfx-crack { animation: vfx-crack-anim 0.5s ease; }
@keyframes vfx-crack-anim {
    0%, 100% { transform: none; filter: none; }
    20% { transform: skewX(1deg); filter: hue-rotate(10deg); }
    40% { transform: skewX(-2deg) translateY(1px); filter: hue-rotate(-5deg) brightness(1.1); }
    60% { transform: skewX(1deg); filter: hue-rotate(5deg); }
    80% { transform: skewX(-0.5deg); }
}

.vfx-rumble { animation: vfx-rumble-anim 0.6s ease; }
@keyframes vfx-rumble-anim {
    0%, 100% { transform: translateY(0); }
    10% { transform: translateY(2px); }
    30% { transform: translateY(3px); }
    50% { transform: translateY(2px); }
    70% { transform: translateY(1px); }
    90% { transform: translateY(-1px); }
}

/* ===== Quick Menu ===== */
.quick-menu {
    position: absolute;
    top: 0.5rem;
    right: 0.8rem;
    z-index: 15;
    display: flex;
    gap: 2px;
}

.qm-btn {
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 240, 245, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.6rem;
    font-size: 0.65rem;
    font-family: var(--font-main);
    cursor: pointer;
    letter-spacing: 0.08em;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 5rem;
}

.qm-btn:first-child {
    border-radius: 0.25rem 0 0 0.25rem;
}

.qm-btn:last-child {
    border-radius: 0 0.25rem 0.25rem 0;
}

.qm-btn:hover {
    background: rgba(255, 183, 197, 0.2);
    color: rgba(255, 240, 245, 0.95);
    border-color: rgba(255, 183, 197, 0.4);
}

.qm-btn.active {
    background: rgba(255, 105, 180, 0.3);
    color: #fff;
    border-color: rgba(255, 105, 180, 0.5);
}

/* ===== Pause Menu ===== */
.pause-container {
    background: linear-gradient(180deg, rgba(30, 15, 25, 0.95), rgba(20, 10, 20, 0.98));
    border: 1px solid rgba(255, 183, 197, 0.2);
    padding: 2rem;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-width: 250px;
    backdrop-filter: blur(10px);
}

/* ===== Backlog Panel ===== */
.backlog-container {
    width: 90%;
    max-width: 700px;
    height: 80%;
    background: linear-gradient(180deg, rgba(20, 10, 18, 0.96), rgba(15, 8, 15, 0.98));
    border: 1px solid rgba(255, 183, 197, 0.15);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
}

.backlog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid rgba(255, 183, 197, 0.1);
}

.backlog-title {
    font-size: 0.85rem;
    color: rgba(255, 183, 197, 0.7);
    letter-spacing: 0.15em;
}

.backlog-close-btn {
    background: none;
    border: none;
    color: rgba(255, 240, 245, 0.5);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.3rem;
    transition: color 0.2s;
}

.backlog-close-btn:hover {
    color: var(--color-primary);
}

.backlog-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.backlog-entry {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.backlog-entry-name {
    font-size: 0.8rem;
    color: var(--color-primary);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.backlog-entry-text {
    font-size: 0.85rem;
    color: rgba(255, 240, 245, 0.75);
    line-height: 1.6;
}

.backlog-content::-webkit-scrollbar {
    width: 4px;
}

.backlog-content::-webkit-scrollbar-track {
    background: transparent;
}

.backlog-content::-webkit-scrollbar-thumb {
    background: rgba(255, 183, 197, 0.2);
    border-radius: 2px;
}

/* ===== CAGE END — 새장 엔딩 ===== */

/* 퀵 메뉴 숨기기 (CAGE 모드) */
.cage-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.5s ease;
}

/* 탈출 버튼 — 오른쪽 상단에 작고 희미하게 등장 */
.cage-exit-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    z-index: 25;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid rgba(200, 162, 200, 0);
    color: rgba(200, 162, 200, 0);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: all 3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* 서서히 나타남 */
.cage-exit-btn.cage-exit-visible {
    border-color: rgba(200, 162, 200, 0.35);
    color: rgba(200, 162, 200, 0.35);
    animation: cage-exit-pulse 3s ease-in-out infinite;
}

.cage-exit-btn.cage-exit-visible:hover {
    border-color: rgba(200, 162, 200, 0.8);
    color: rgba(200, 162, 200, 0.9);
    background: rgba(200, 162, 200, 0.1);
    text-shadow: 0 0 8px rgba(200, 162, 200, 0.5);
    transition: all 0.3s ease;
}

@keyframes cage-exit-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .title-text { font-size: 1.8rem; }
    .dialogue-box { padding: 0.8rem 1rem 1.2rem; min-height: 120px; }
    .dialogue-text { font-size: 0.9rem; }
    .choice-btn { font-size: 0.85rem; padding: 0.7rem 1.5rem; }
    .quick-menu { gap: 1px; }
    .qm-btn { padding: 0.2rem 0.4rem; font-size: 0.6rem; }
    .backlog-container { width: 95%; height: 85%; }
}

/* ===== 모바일 가로모드 최적화 ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .dialogue-box {
        padding: 0.5rem 1rem 0.8rem;
        min-height: 90px;
    }
    .speaker-name {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
        padding: 0.1rem 0.6rem;
    }
    .dialogue-text {
        font-size: 0.82rem;
        line-height: 1.5;
        min-height: 2em;
    }
    .character-sprite {
        height: 95%;
    }
    .char-crossfade-out {
        height: 95%;
    }
    .quick-menu {
        top: 0.3rem;
        right: 0.5rem;
        gap: 1px;
    }
    .qm-btn {
        padding: 0.15rem 0.35rem;
        font-size: 0.55rem;
    }
    .click-indicator {
        bottom: 0.4rem;
        right: 0.8rem;
        font-size: 0.7rem;
    }
    .choice-container {
        gap: 0.4rem;
    }
    .choice-btn {
        font-size: 0.8rem;
        padding: 0.5rem 1.2rem;
    }
    .backlog-container {
        width: 95%;
        height: 90%;
    }
}

/* ===== Rotate Prompt (모바일/태블릿 세로모드 → 가로 회전 안내) ===== */
.rotate-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    gap: 1.5rem;
}

.rotate-prompt .rotate-icon {
    font-size: 4rem;
    animation: rotate-phone 2s ease-in-out infinite;
}

.rotate-prompt .rotate-text {
    font-size: 1.1rem;
    font-family: var(--font-main);
    letter-spacing: 0.05em;
    opacity: 0.85;
    line-height: 1.6;
}

@keyframes rotate-phone {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-30deg); }
    75% { transform: rotate(90deg); }
}

/* 터치 디바이스 + 세로모드일 때만 표시 */
@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
    .rotate-prompt {
        display: flex !important;
    }
}

/* ===== Gallery Screen ===== */
#gallery-screen {
    background: #0a0008;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.gallery-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.gallery-title {
    font-size: 1.3rem;
    font-weight: 500;
    color: rgba(255, 183, 197, 0.85);
    letter-spacing: 0.15em;
}

.gallery-progress-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-progress-label {
    font-size: 0.8rem;
    color: rgba(255, 183, 197, 0.5);
    letter-spacing: 0.1em;
}

#gallery-progress {
    font-size: 0.85rem;
    color: rgba(255, 240, 245, 0.7);
    font-weight: 500;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.gallery-card {
    background: linear-gradient(180deg, rgba(30, 15, 25, 0.85), rgba(20, 10, 20, 0.95));
    border: 1px solid rgba(255, 183, 197, 0.15);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    /* i18n: de/fr 긴 텍스트에도 레이아웃 유지 */
    min-height: 160px;
}

.gallery-card.gallery-unlocked {
    border-color: rgba(255, 183, 197, 0.3);
}

.gallery-card.gallery-unlocked:hover {
    border-color: rgba(255, 183, 197, 0.5);
    background: linear-gradient(180deg, rgba(40, 20, 35, 0.9), rgba(25, 12, 25, 0.98));
    box-shadow: 0 0 20px rgba(255, 105, 180, 0.1);
}

.gallery-card.gallery-locked {
    opacity: 0.4;
    filter: grayscale(0.5);
}

.gallery-card-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
    text-shadow: 0 0 10px rgba(255, 105, 180, 0.3);
    height: 2rem;
    display: flex;
    align-items: center;
}

.gallery-locked .gallery-card-icon::before {
    content: '\1F512';
    font-size: 1.2rem;
}

.gallery-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 240, 245, 0.9);
    letter-spacing: 0.1em;
    /* i18n: 긴 엔딩 제목 잘림 방지 */
    word-break: keep-all;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.gallery-locked .gallery-card-title {
    color: rgba(255, 240, 245, 0.4);
}

.gallery-card-desc {
    font-size: 0.8rem;
    color: rgba(255, 240, 245, 0.6);
    line-height: 1.5;
    font-weight: 300;
    /* i18n: 긴 설명 텍스트(de/fr) 처리 */
    word-break: keep-all;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.gallery-locked .gallery-card-desc {
    color: rgba(255, 240, 245, 0.3);
    font-style: italic;
}

#gallery-back {
    background: rgba(255, 183, 197, 0.15);
    color: rgba(255, 240, 245, 0.9);
    border: 1px solid rgba(255, 183, 197, 0.3);
    padding: 0.6rem 2rem;
    font-size: 0.9rem;
    font-family: var(--font-main);
    border-radius: 0.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.15em;
}

#gallery-back:hover {
    background: rgba(255, 183, 197, 0.3);
    border-color: rgba(255, 183, 197, 0.6);
    color: #fff;
}

.gallery-footer {
    text-align: center;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    #gallery-screen {
        padding: 1.5rem 0.8rem;
    }
    .gallery-title {
        font-size: 1.1rem;
    }
    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 0.8rem;
    }
    .gallery-card {
        padding: 1.2rem;
        min-height: 140px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    #gallery-screen {
        padding: 1rem 0.8rem;
    }
    .gallery-header {
        margin-bottom: 1rem;
    }
    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 0.6rem;
    }
    .gallery-card {
        padding: 0.8rem;
        min-height: 110px;
    }
    .gallery-card-icon {
        font-size: 1.2rem;
        height: 1.5rem;
    }
}

/* ===== Ending Title Overlay ===== */
.ending-title-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    animation: fadeIn 2s ease forwards;
}

.ending-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.15em;
    text-shadow: 0 0 20px rgba(255, 183, 197, 0.5);
}

.ending-subtitle {
    font-size: 1rem;
    color: rgba(255, 240, 245, 0.7);
    margin-top: 1rem;
    font-style: italic;
    letter-spacing: 0.05em;
}

/* ===== Loading Screen ===== */
#loading-screen {
    background: #0a0008;
    z-index: 200;
}

.loading-container {
    text-align: center;
    width: 80%;
    max-width: 400px;
}

.loading-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: rgba(255, 183, 197, 0.8);
    margin-bottom: 2rem;
    text-shadow: 0 0 15px rgba(255, 105, 180, 0.3);
}

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

.loading-bar-inner {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    border-radius: 2px;
    transition: width 0.15s ease;
    box-shadow: 0 0 8px rgba(255, 105, 180, 0.4);
}

.loading-text {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: rgba(255, 240, 245, 0.5);
    letter-spacing: 0.1em;
}

/* ===== Stat Change Popup (+5, -3) ===== */
.stat-change-popup {
    position: absolute;
    left: 50%;
    top: 20%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    font-weight: 700;
    pointer-events: none;
    animation: stat-popup-rise 1.5s ease forwards;
    text-shadow: 0 0 4px rgba(0, 0, 0, 1), 0 0 8px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.9);
    z-index: 50;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.stat-change-up {
    color: #ff6b9d;
}

.stat-change-down {
    color: #6ec6ff;
}

@keyframes stat-popup-rise {
    0% { opacity: 0; transform: translateX(-50%) translateY(0) scale(0.8); }
    15% { opacity: 1; transform: translateX(-50%) translateY(-8px) scale(1.1); }
    30% { opacity: 1; transform: translateX(-50%) translateY(-12px) scale(1); }
    70% { opacity: 1; transform: translateX(-50%) translateY(-20px); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-35px); }
}

/* ===== Heart Effect (Affinity Up) ===== */
.heart-effect-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 25;
}

.heart-particle {
    position: absolute;
    bottom: 30%;
    color: #ff6b9d;
    opacity: 0;
    pointer-events: none;
    text-shadow: 0 0 6px rgba(255, 107, 157, 0.5);
    animation: heart-float 1.8s ease forwards;
}

@keyframes heart-float {
    0% { opacity: 0; transform: translateY(0) scale(0.5); }
    15% { opacity: 0.9; transform: translateY(-10px) scale(1); }
    50% { opacity: 0.7; transform: translateY(-40px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-80px) scale(0.6); }
}

/* ===== Save Toast ===== */
.save-toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: rgba(0, 0, 0, 0.7);
    color: rgba(255, 240, 245, 0.95);
    padding: 0.5rem 1.5rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    font-family: var(--font-main);
    letter-spacing: 0.08em;
    border: 1px solid rgba(255, 183, 197, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999;
    pointer-events: none;
}

.save-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.save-toast-hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
}

/* 태블릿 포함: 터치 + 세로 + 화면 너비 1024px 이하 */
@media (any-pointer: coarse) and (orientation: portrait) and (max-width: 1024px) {
    .rotate-prompt {
        display: flex !important;
    }
}
