/* ========================================
   Base Styles & Variables
======================================== */
:root {
    --primary-color: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary-color: #ec4899;
    --bg-dark: #0f0f1a;
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-window-bg: rgba(15, 15, 26, 0.92);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Zen Maru Gothic', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    /* Dynamic viewport height for mobile */
}

/* ========================================
   Game Container
======================================== */
#game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Title Screen
======================================== */
#title-screen {
    background: var(--bg-gradient);
    background-image: url('assets/images/backgrounds/title_bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(15, 15, 26, 0.7) 0%, rgba(26, 26, 46, 0.5) 50%, rgba(79, 70, 100, 0.4) 100%);
    z-index: 1;
}

/* 全エンディングクリア後のタイトル画面 */
#title-screen.true-ending {
    background-image: url('assets/images/backgrounds/title_bg_true.jpg');
}

#title-screen.true-ending::before {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(236, 72, 153, 0.2) 50%, rgba(139, 92, 246, 0.3) 100%);
}

.title-content {
    text-align: center;
    z-index: 10;
    animation: fadeInUp 1.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

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

.game-title {
    font-family: 'Zen Maru Gothic', serif;
    font-size: clamp(2.5rem, 7vw, 5rem);
    font-weight: 700;
    background: linear-gradient(135deg, #e0e0e0 0%, #a0a0a0 30%, #808080 50%, #c0c0c0 70%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(160, 160, 160, 0.5);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    line-height: 1.3;
}

.subtitle {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-weight: 300;
    letter-spacing: 0.2em;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.menu-btn {
    position: relative;
    padding: clamp(0.75rem, 2vh, 1rem) clamp(2rem, 6vw, 4rem);
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
}

.menu-btn:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 40px var(--primary-glow);
}

.menu-btn .btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.menu-btn:hover .btn-glow {
    left: 100%;
}

.menu-btn.secondary {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(100, 116, 139, 0.15));
    padding: clamp(0.5rem, 1.5vh, 0.8rem) clamp(1.5rem, 4vw, 3rem);
    font-size: clamp(0.85rem, 1.6vw, 1rem);
}

.menu-btn.secondary:hover {
    border-color: var(--text-secondary);
    box-shadow: 0 10px 40px rgba(148, 163, 184, 0.3);
}

/* Particles */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0.6;
    animation: float 15s infinite ease-in-out;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

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

.background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 0.8s ease, opacity 0.8s ease;
}

/* CG Overlay */
.cg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 15;
    /* キャラクター(10)より上、UI(100)より下 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.cg-overlay.active {
    opacity: 1;
    visibility: visible;
}

.character-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    padding-bottom: clamp(100px, 18vh, 180px);
}

.character {
    position: absolute;
    bottom: 0;
    max-height: 95%;
    max-width: 60%;
    object-fit: contain;
    transition: opacity 0.5s ease, transform 0.5s ease, left 0.5s ease, right 0.5s ease;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

.character.left {
    left: 5%;
    transform: translateX(0);
}

.character.center {
    left: 50%;
    transform: translateX(-50%);
}

.character.right {
    right: 5%;
    left: auto;
    transform: translateX(0);
}

@keyframes characterEnter {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.character.entering {
    animation: characterEnter 0.5s ease-out forwards;
}

/* ========================================
   Text Window
======================================== */
.text-window {
    position: absolute;
    bottom: clamp(0.5rem, 2vh, 1.5rem);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - clamp(1rem, 3vw, 4rem));
    max-width: min(900px, 95vw);
    height: clamp(100px, 20vh, 160px);
    background: var(--text-window-bg);
    border: 1px solid var(--glass-border);
    border-radius: clamp(6px, 1vw, 12px);
    padding: clamp(0.5rem, 1.5vh, 1rem) clamp(0.75rem, 2vw, 1.5rem);
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px var(--shadow-color);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.text-window:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.speaker-name {
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: clamp(0.25rem, 0.5vh, 0.5rem);
    flex-shrink: 0;
    text-shadow: 0 0 20px var(--primary-glow);
}

.text-content {
    font-size: clamp(0.85rem, 1.5vw, 1.05rem);
    line-height: 1.8;
    color: var(--text-primary);
    flex: 1;
    overflow-y: auto;
    white-space: pre-wrap;
}

.text-window-hide {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.text-window-hide:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.text-window.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.click-indicator {
    position: absolute;
    bottom: 0.75rem;
    right: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    animation: bounce 1s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(5px);
    }
}

/* ========================================
   Choices
======================================== */
.choices-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: calc(100% - 4rem);
    max-width: 600px;
    z-index: 100;
}

.choice-btn {
    padding: clamp(0.75rem, 2vh, 1.25rem) clamp(1rem, 3vw, 2rem);
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.15));
    border: 1px solid var(--glass-border);
    border-radius: clamp(8px, 1.5vw, 12px);
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
    text-align: left;
    animation: choiceFadeIn 0.5s ease-out backwards;
}

.choice-btn.choice-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.choice-btn:nth-child(1) {
    animation-delay: 0.1s;
}

.choice-btn:nth-child(2) {
    animation-delay: 0.2s;
}

.choice-btn:nth-child(3) {
    animation-delay: 0.3s;
}

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

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

.choice-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(236, 72, 153, 0.3));
    border-color: var(--primary-color);
    transform: translateX(10px);
    box-shadow: 0 0 30px var(--primary-glow);
}

/* ========================================
   UI Controls
======================================== */
.ui-controls {
    position: absolute;
    top: clamp(0.75rem, 2vw, 1.5rem);
    right: clamp(0.75rem, 2vw, 1.5rem);
    display: flex;
    gap: clamp(0.4rem, 1vw, 0.75rem);
    z-index: 100;
}

.ui-btn {
    width: clamp(36px, 5vw, 44px);
    height: clamp(36px, 5vw, 44px);
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: clamp(6px, 1vw, 10px);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
}

.ui-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-glow);
}

.ui-btn.active {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.2);
}

/* ========================================
   Loading Screen
======================================== */
#loading-screen {
    background: var(--bg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.loading-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
}

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

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

/* タブレット (768px以下) */
@media (max-width: 768px) {
    .text-window {
        bottom: 1rem;
        width: calc(100% - 2rem);
        padding: 1rem 1.25rem;
    }

    .text-content {
        font-size: 1rem;
    }

    .ui-controls {
        top: 1rem;
        right: 1rem;
    }

    .choice-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .game-title {
        font-size: clamp(2rem, 6vw, 3.5rem);
    }

    .subtitle {
        font-size: clamp(0.9rem, 2vw, 1.2rem);
    }
}

/* スマホ (480px以下) */
@media (max-width: 480px) {
    .game-title {
        font-size: clamp(1.5rem, 8vw, 2.5rem);
    }

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

    .menu-btn {
        padding: 0.8rem 2.5rem;
        font-size: 1rem;
    }

    .menu-btn.secondary {
        padding: 0.6rem 2rem;
        font-size: 0.9rem;
    }

    .character {
        max-height: 75%;
        max-width: 80%;
    }

    .character-layer {
        padding-bottom: 140px;
    }

    .text-window {
        padding: 0.8rem 1rem;
    }

    .speaker-name {
        font-size: 0.95rem;
    }

    .text-content {
        font-size: 0.9rem;
        line-height: 1.7;
    }

    .ui-btn {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
}

/* 縦向きスマホ専用 (portrait) */
@media (max-width: 768px) and (orientation: portrait) {
    .character {
        max-height: 60%;
        max-width: 90%;
    }

    .character-layer {
        height: 70%;
        padding-bottom: 120px;
    }

    .character.left {
        left: 0;
    }

    .character.right {
        right: 0;
    }
}

/* 横向き推奨メッセージ */
.rotate-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.rotate-message .rotate-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-20deg);
    }

    75% {
        transform: rotate(20deg);
    }
}

.rotate-message h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.rotate-message .skip-rotate {
    margin-top: 2rem;
    padding: 0.8rem 2rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.rotate-message .skip-rotate:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

/* 縦向き時に推奨メッセージ表示 */
@media (max-width: 600px) and (orientation: portrait) {
    .rotate-message:not(.hidden) {
        display: flex;
    }
}

/* ========================================
   Save/Load Modal
======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.98), rgba(15, 52, 96, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    animation: modalSlideIn 0.3s ease-out;
}

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

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

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

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.2);
}

.modal-body {
    padding: 1.5rem 2rem;
    max-height: calc(85vh - 80px);
    overflow-y: auto;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* データ管理（危険ゾーン）*/
.settings-danger {
    border-color: rgba(239, 68, 68, 0.3);
}

.settings-danger .settings-section-title {
    color: #ef4444;
}

.settings-danger-info {
    margin-bottom: 1rem;
}

.settings-danger-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.settings-warning {
    color: #ef4444 !important;
    font-weight: 600;
}

.settings-btn.danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(185, 28, 28, 0.2));
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #ef4444;
}

.settings-btn.danger:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(185, 28, 28, 0.4));
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

/* ========================================
   Save Slots Grid
======================================== */
.save-slots-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 600px) {
    .save-slots-grid {
        grid-template-columns: 1fr;
    }
}

.save-slot {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.save-slot:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.2);
}

.save-slot.has-data {
    border-color: rgba(99, 102, 241, 0.3);
}

.save-slot.empty {
    opacity: 0.6;
}

.save-slot.empty:hover {
    opacity: 1;
}

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

.slot-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-color);
}

.slot-delete {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #ef4444;
    cursor: pointer;
    transition: var(--transition-smooth);
    opacity: 0;
}

.save-slot:hover .slot-delete {
    opacity: 1;
}

.slot-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.slot-info {
    font-size: 0.85rem;
}

.slot-route {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.slot-preview {
    color: var(--text-primary);
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.slot-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.slot-empty {
    color: var(--text-secondary);
    font-style: italic;
}

/* ========================================
   Game Notification
======================================== */
.game-notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(139, 92, 246, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 2000;
    animation: notificationSlideIn 0.3s ease-out;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
}

.game-notification.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.4);
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.game-notification.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ========================================
   Gallery Styles
======================================== */
.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.gallery-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

.ending-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.ending-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

.ending-card.unlocked {
    border-left: 3px solid var(--primary-color);
}

.ending-card.locked {
    border-left: 3px solid var(--text-secondary);
    opacity: 0.7;
}

.ending-number {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: 0.1em;
}

.ending-card.locked .ending-number {
    color: var(--text-secondary);
}

.ending-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.ending-title.locked-title {
    color: var(--text-secondary);
    font-style: italic;
}

.ending-route {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.ending-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.bgm-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.bgm-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bgm-card.playing {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.bgm-name {
    color: var(--text-primary);
    font-weight: 500;
}

.bgm-play-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bgm-play-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

/* ========================================
   Mobile Responsive (allow natural scroll)
======================================== */
@media screen and (max-height: 600px) {

    /* Allow body to scroll */
    body {
        overflow-y: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #game-container {
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
    }

    /* Title screen - compact layout */
    .title-content {
        padding: 1rem;
    }

    .game-title {
        font-size: clamp(1.5rem, 5vw, 3rem);
        margin-bottom: 0.3rem;
    }

    .subtitle {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .title-menu {
        gap: 0.3rem;
    }

    .title-btn {
        padding: 0.5rem 1.5rem;
        font-size: 0.85rem;
    }
}

/* Very small mobile screens (portrait) */
@media screen and (max-width: 480px) and (orientation: portrait) {
    .game-title {
        font-size: 1.8rem;
    }

    .text-content {
        font-size: 0.9rem;
    }

    .choice-btn {
        font-size: 0.9rem;
        padding: 0.8rem;
    }
}