﻿/* Reset & Base */
body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    /* Mobile Fix */
    overflow: hidden;
    font-family: 'Zen Maru Gothic', sans-serif;
    background-color: #000;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    display: flex;
    /* Center Game */
    justify-content: center;
    align-items: center;
}

img {
    -webkit-user-drag: none;
    user-drag: none;
}

/* Chapter End Logo (Moved inside container so positioned relative to it) */
#chapter-end-logo {
    position: absolute;
    bottom: 3cqh;
    /* was 3cqh */
    right: 3cqw;
    /* was 3cqw */
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 3s ease-in-out;
}

#chapter-end-logo img {
    width: 20cqw;
    /* was 20cqw */
    height: auto;
}

#game-container {
    position: relative;
    /* Aspect Ratio Locking */
    width: 100%;
    max-width: 177.778vh;
    /* 16/9 * 100cqh */
    aspect-ratio: 16 / 9;

    /* Ensure it fits in height as well if width is constrained */
    max-height: 56.25vw;
    /* 9/16 * 100cqw */

    background-color: #000;
    overflow: hidden;
    /* Mask content outside 16:9 */
    container-type: size;
    /* Enable Container Queries (cqw/cqh) */
}

/* Background Image Layer */
#background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
    transition: background-image 0.5s ease-in-out;
}

/* Effect Layer */
#fireCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
    opacity: 1;
}

/* Flash Overlay */
/* Flash Overlay */
#flash-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    /* Giant Border Hack: Forces white even if background is inverted */
    border: 999vmax solid white;
    transform: translate(-50%, -50%);
    background: none;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.05s linear;
    isolation: isolate;
    /* Backup: Filter hacks */
    filter: brightness(1) contrast(1) sepia(0) hue-rotate(0) !important;
}

#flash-overlay.visible {
    opacity: 1;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through to background if needed */
}

/* Message Window */
/* Message Area Wrapper (Positioning & Transition) */
#message-area-wrapper {
    position: absolute;
    bottom: 1.04cqw;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 62.5cqw;
    display: flex;
    flex-direction: column;
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none;
    /* Let clicks pass through gaps */
    z-index: 10;
}

#message-area-wrapper.message-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(50px);
}

/* Message Window (Visuals Only) */
#message-window {
    /* Position handled by wrapper */
    width: 100%;
    height: 12.66cqw;
    /* Reduced to 3/4 (22.5cqh @ 1080p = 243px) */
    min-height: 9.9cqw;
    background-image: url('../Assets/Image/UI/メッセージウィンドウ.png');
    background-size: 100% 100%;
    /* Stretch to fit */
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    border-radius: 0;
    padding: 1.56cqw 2.08cqw;
    box-sizing: border-box;
    pointer-events: auto;
    /* Enable clicks on window */
    display: flex;
    flex-direction: column;
}

/* Name Plate */
#name-plate {
    position: absolute;
    top: -1.82cqw;
    /* Adjusted overlap */
    left: 1.04cqw;
    background-image: url('../Assets/Image/UI/名前ウィンドウ.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-color: transparent;
    color: #fff;
    padding: 0.26cqw 1.56cqw 0.52cqw 1.56cqw;
    /* Adjust padding for text centering */
    border: none;
    border-radius: 0;
    font-size: 1.25cqw;
    font-weight: bold;
    min-width: 10.42cqw;
    /* Ensure wide enough for image */
    text-align: center;
    z-index: 15;
}

/* Message Text */
#message-text {
    flex-grow: 1;
    color: #fff;
    font-size: 1.46cqw;
    /* Increased size (approx 1.25x) */
    line-height: 1.5;
    margin-top: -0.26cqw;
    /* Move text up */
    margin-left: 0.52cqw;
    margin-right: 0.52cqw;
    overflow-y: hidden;
    text-shadow: 1px 1px 2px #000;
}

/* System Menu Buttons */
#system-menu {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 0.26cqw;
    margin-top: 0.52cqw;
    /* Space between window and buttons */
    margin-bottom: 0;
    padding: 0 0.52cqw;
    /* Slight inner padding */
    box-sizing: border-box;
    pointer-events: auto;
    /* Enable clicks */
}

.sys-btn {
    background-image: url('../Assets/Image/UI/ボタンUI.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    color: #eee;
    padding: 0.42cqw 2.34cqw;
    /* Increased width (1.5x) */
    font-family: inherit;
    font-size: 0.83cqw;
    cursor: pointer;
    border-radius: 0;
    transition: filter 0.2s, transform 0.1s;
    text-shadow: 1px 1px 2px #000;
}

.sys-btn:hover {
    filter: brightness(1.2);
    color: #fff;
    transform: scale(1.05);
}

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

/* Config Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s;
    pointer-events: auto;
    /* Ensure clickable */
}

/* Save/Load Modal */
#save-load-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../Assets/Image/BackGround/セーブロード画面/system_セーブロード画面.jpg');
    background-size: cover;
    background-position: center;
    z-index: 10000;
    /* Super high z-index */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 5cqh;
    box-sizing: border-box;
    color: #fff;
    font-family: 'Zen Maru Gothic', sans-serif;
    pointer-events: auto;
    /* Force enable clicks */
}

/* Start Overlay */
#game-start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    /* Invisible */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    cursor: default;
    /* Standard cursor so user doesn't know it's a button */
    transition: opacity 0.5s ease-out;
}

#game-start-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#start-message {
    color: #fff;
    font-size: 2cqw;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: rgba(30, 30, 30, 0.95);
    color: #fff;
    padding: 1.56cqw;
    border: 0.10cqw solid #777;
    border-radius: 0.52cqw;
    width: 20.83cqw;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 0 1.04cqw rgba(0, 0, 0, 0.8);
    font-size: 1cqw;
    /* Base scaling text */
}

.modal-content h2 {
    font-size: 1.5cqw;
    margin-top: 0;
    margin-bottom: 1cqw;
    border-bottom: 1px solid #555;
    padding-bottom: 0.5cqw;
}

.config-item {
    margin: 0.5cqw 0;
    /* Reduced from 1.04cqw */
    display: flex;
    flex-direction: column;
    gap: 0.2cqw;
    /* Reduced from 0.52cqw */
    align-items: center;
    /* Center items in config */
}

#config-cache-item {
    margin-top: -0.25cqw;
    /* Move slightly up */
    margin-bottom: 0.8cqw;
    display: flex;
    flex-direction: column;
    /* Vertical to avoid narrow overflow */
    gap: 0.8cqw;
    align-items: center;
}

#manual-preload-btn,
#config-clear-cache-btn {
    width: 14cqw;
    padding: 0.3cqw 0;
    font-size: 0.85cqw;
}

#config-clear-cache-btn {
    background: rgba(255, 68, 68, 0.2);
    border: 1px solid rgba(255, 68, 68, 0.4);
}

#config-clear-cache-btn:hover {
    background: rgba(255, 68, 68, 0.4);
}

#config-close-btn {
    margin-top: 3cqw;
    /* Move down */
}

#text-speed-slider,
#bgm-volume-slider,
#se-volume-slider {
    width: 100%;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 1.2cqw;
    /* Tap target size */
}

/* Slider Track */
/* Slider Track */
#text-speed-slider::-webkit-slider-runnable-track,
#bgm-volume-slider::-webkit-slider-runnable-track,
#se-volume-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 0.4cqw;
    /* Visible Track thickness */
    background: linear-gradient(to right, #198744 var(--percent, 50%), #aaa var(--percent, 50%));
    border-radius: 999px;
    /* Max rounding */
    cursor: pointer;
}

/* Slider Thumb */
/* Slider Thumb */
#text-speed-slider::-webkit-slider-thumb,
#bgm-volume-slider::-webkit-slider-thumb,
#se-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 1.2cqw;
    width: 1.2cqw;
    border-radius: 50%;
    background: #198744;
    cursor: pointer;
    margin-top: -0.4cqw;
    /* Center: (0.4/2 - 1.2/2) = 0.2 - 0.6 = -0.4 */
    box-shadow: 0 0 0.2cqw rgba(0, 0, 0, 0.5);
}

#text-speed-slider:focus,
#bgm-volume-slider:focus,
#se-volume-slider:focus {
    outline: none;
}


#speed-preview,
#bgm-preview,
#se-preview {
    font-size: 1.00cqw;
    height: 1.67cqw;
    margin-top: 0.52cqw;
}

/* Text Fade Animation */
.char-span {
    opacity: 0;
    display: inline-block;
    transition: opacity 0.5s ease-out;
    /* Smooth fade in */
}

.char-span.visible {
    opacity: 1;
}

/* Log Modal Specifics */
.log-content {
    width: 31.25cqw;
    /* Wider than config */
    height: 39.38cqw;
    display: flex;
    flex-direction: column;
}

#log-list {
    flex-grow: 1;
    overflow-y: auto;
    text-align: left;
    margin-bottom: 1.04cqw;
    padding: 0.52cqw;
    border: 0.05cqw solid #555;
    background: rgba(0, 0, 0, 0.5);
}

.log-entry {
    margin-bottom: 0.78cqw;
    border-bottom: 0.05cqw solid #333;
    padding-bottom: 0.26cqw;
}

.log-speaker {
    font-weight: bold;
    color: #ffd700;
    font-size: 0.75cqw;
}

.log-text {
    margin-top: 0.26cqw;
    font-size: 0.83cqw;
}

.log-choice {
    color: #ffd700;
    /* Yellow text for choices */
    font-weight: bold;
    margin-top: 0.26cqw;
    font-size: 0.83cqw;
}

/* Status Indicator */
#status-indicator {
    position: absolute;
    top: 2cqh;
    right: 2cqw;
    color: #fff;
    font-size: 3cqw;
    font-weight: bold;
    text-shadow: 0 0 0.2cqw #000;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.5s;
}

#status-indicator.hidden {
    display: none;
}

#status-indicator.status-blink {
    animation: blink-anim 2s infinite;
}

@keyframes blink-anim {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* Chapter Title Screen */
#chapter-title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 2000;
    /* Topmost */
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    /* Allow clicks to pass through if needed, though usually blocking is better during intro */
    pointer-events: auto;
    /* Blocking clicks during intro is safer */
    transition: opacity 3s ease-in-out;
    /* Fade out of screen */
}

#chapter-title-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#title-content {
    text-align: center;
    color: #fff;
}

#episode-label {
    font-size: 2.5cqw;
    /* 2rem @ 1280px */
    margin-bottom: 20px;
    opacity: 0;
    transition: opacity 3s ease-in-out;
}

#chapter-title {
    font-size: 5cqw;
    /* 4rem @ 1280px */
    font-family: 'Zen Maru Gothic', serif;
    /* Use serif or the loaded font */
    opacity: 0;
    transition: opacity 3s ease-in-out;
    position: relative;
    /* Needed for pseudo-elements */
}

/* Glitch Effect */
.glitch {
    color: white;
    position: relative;
}

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

.glitch::before {
    color: #ff00c1;
    z-index: -1;
    animation: glitch-anim-1 0.3s infinite linear alternate-reverse;
}

.glitch::after {
    color: #00fff9;
    z-index: -2;
    animation: glitch-anim-2 0.3s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% {
        clip-path: inset(20% 0 80% 0);
        transform: translate(-4px, 2px);
    }

    20% {
        clip-path: inset(60% 0 10% 0);
        transform: translate(4px, -2px);
    }

    40% {
        clip-path: inset(40% 0 50% 0);
        transform: translate(-4px, 4px);
    }

    60% {
        clip-path: inset(80% 0 5% 0);
        transform: translate(4px, -4px);
    }

    80% {
        clip-path: inset(10% 0 60% 0);
        transform: translate(-2px, 2px);
    }

    100% {
        clip-path: inset(50% 0 30% 0);
        transform: translate(2px, -2px);
    }
}

@keyframes glitch-anim-2 {
    0% {
        clip-path: inset(10% 0 60% 0);
        transform: translate(4px, -2px);
    }

    20% {
        clip-path: inset(30% 0 20% 0);
        transform: translate(-4px, 4px);
    }

    40% {
        clip-path: inset(70% 0 10% 0);
        transform: translate(4px, -4px);
    }

    60% {
        clip-path: inset(20% 0 50% 0);
        transform: translate(-4px, 2px);
    }

    80% {
        clip-path: inset(60% 0 20% 0);
        transform: translate(2px, -4px);
    }

    100% {
        clip-path: inset(40% 0 80% 0);
        transform: translate(-2px, 4px);
    }
}



/* Character Layer */
#character-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    /* Between Background (1) and UI (10) */
    pointer-events: none;
    display: flex;
    justify-content: center;
    /* Default center */
    align-items: flex-end;
    /* Align bottom */
}

.character-img {
    position: absolute;
    bottom: -15cqh;
    /* Fixed to bottom */
    height: 110cqh;
    /* Adjusted from 80cqh (1.1x) */
    width: auto;
    /* Preserve aspect ratio */
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out, filter 0.3s ease-out;
    opacity: 0;
}

.character-img.dimmed {
    filter: brightness(0.5);
}

.character-img.visible {
    opacity: 1;
}

#episode-label.visible,
#chapter-title.visible {
    opacity: 1;
}

/* Choice System */
#choice-container {
    position: absolute;
    top: auto;
    /* Remove top constraint */
    left: 0;
    width: 100%;
    height: auto;
    bottom: 24cqw;
    /* Lowered slightly (was 27cqw) */
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Stack upwards from anchor */
    align-items: center;
    /* Dim background removed */
    padding-bottom: 0;
    /* Reset padding */
    gap: 4cqw;
    box-sizing: border-box;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Let clicks pass through (background) */
}

#choice-container.hidden,
#choice-container.visually-hidden {
    opacity: 0;
    pointer-events: none;
}

.choice-btn {
    pointer-events: auto;
    /* Enable clicks on buttons */
    width: 68cqw;
    /* Matches reference image width (approx 1300px @ 1920) */
    height: 5.5cqw;
    /* Matches reference image height (approx 105px @ 1920) */
    background-image: url('../Assets/Image/UI/ChoiceUI.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    border: none;
    color: #000 !important;
    /* Black text */
    font-size: 1.8cqw;
    /* Adjusted for thinner bar */
    font-family: 'Zen Maru Gothic', sans-serif;
    cursor: pointer;
    /* Removed shadow for black text, or could use white outline if needed. Assume plain black for now */
    text-shadow: none;
    transition: transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 0.20cqw;
}

.choice-btn:hover {
    transform: scale(1.05);
}

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

.choice-btn.selected {
    transform: scale(1.15);
    /* Gradually larger */
    opacity: 0;
    transition: transform 1s ease-out, opacity 1s ease-out;
    pointer-events: none;
}

.choice-btn.unselected {
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none;
}

/* Save/Load System */
/* Save/Load System (Moved to top) */

#save-load-modal.hidden {
    display: none;
}

#save-load-title {
    font-size: 3cqw;
    margin-bottom: 2cqh;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.5), transparent);
    padding: 0.5cqw 5cqw;
    border-top: 1px solid rgba(255, 215, 0, 0.5);
    /* Gold hint */
    border-bottom: 1px solid rgba(255, 215, 0, 0.5);
}

#save-load-close {
    position: absolute;
    bottom: 5cqh;
    right: 5cqw;
    /* Styles inherited from .sys-btn */
    pointer-events: auto;
    /* Force enable clicks */
    z-index: 300;
    /* Ensure on top of slots */
}

.no-data {
    color: #fff;
    font-size: 1.5cqw;
    margin-top: 10cqh;
    text-align: center;
    width: 60%;
    margin-left: auto;
    margin-right: auto;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 3cqh;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#slot-container {
    width: 80%;
    height: 70cqh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5cqh;
    padding-right: 1cqw;
    /* Custom Scrollbar styling if needed */
}

/* Scrollbar for webkit */
#slot-container::-webkit-scrollbar {
    width: 8px;
}

#slot-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.save-slot {
    display: flex;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 12cqh;
    /* Adjust based on content */
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    overflow: hidden;
    flex-shrink: 0;
    /* Prevent shrinking when scrolling */
}

.save-slot.deleting-hold {
    background: rgba(200, 50, 50, 0.8) !important;
    border-color: rgba(255, 50, 50, 0.9) !important;
    transition: background 2s linear, border-color 2s linear;
}

.save-slot:hover {
    background: rgba(50, 50, 50, 0.8);
    border-color: rgba(255, 215, 0, 0.6);
}

.slot-thumb {
    width: 20cqh;
    /* Aspect ratio roughly 16:9 */
    flex-shrink: 0;
    /* Prevent shrinking */
    background-color: #000;
    background-size: cover;
    background-position: center;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.slot-thumb.empty {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2cqw;
    color: #555;
    font-weight: bold;
    letter-spacing: 0.1em;
}

.slot-info {
    flex: 1;
    padding: 1cqh 1.0cqw;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.5cqh;
}

.slot-header {
    display: flex;
    justify-content: space-between;
    font-size: 1cqw;
    color: #ffd700;
    margin-bottom: 0.5cqh;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5cqh;
}

.slot-date {
    font-family: monospace;
    font-size: 0.9cqw;
    color: #ccc;
}

.slot-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.5em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-chapter-title {
    font-size: 1.1cqw;
    /* Title size */
    color: #ffd700;
    /* Gold */
    font-weight: bold;
    margin-bottom: 0.5cqh;
}

.slot-text {
    font-size: 1.0cqw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #eee;
    opacity: 0.8;
}

.slot-location {
    font-size: 0.8cqw;
    color: #aaa;
    text-align: right;
}

/* Confirm Modal Styles */
.confirm-content {
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #ffd700;
    border-radius: 8px;
    padding: 3cqh 3cqw;
    text-align: center;
    min-width: 40cqw;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

#confirm-message {
    color: #fff;
    font-size: 1.3cqw;
    margin-bottom: 4cqh;
    white-space: pre-wrap;
    line-height: 1.6;
}

#confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 5cqw;
    /* Increased spacing between Yes/No */
    margin-top: 2cqh;
}

/* Fullscreen Button */
#fullscreen-btn {
    position: absolute;
    top: 8cqh;
    right: 2cqw;
    width: 5cqw;
    height: 5cqw;
    padding: 0;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    z-index: 99999;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s, transform 0.2s;
}

#fullscreen-btn:active {
    transform: scale(0.9);
    background-color: rgba(0, 0, 0, 0.8);
}

#fullscreen-btn svg {
    width: 60%;
    height: 60%;
}

/* Hide on Desktop by default, show via JS or Media Query if needed */
/* For now, we'll let JS decide 'hidden' class, but ensure display is flex when not hidden */
#fullscreen-btn.hidden {
    display: none !important;
}

/* Background Shake Animation */
@keyframes shake-anim {
    0% {
        transform: scale(1.05) translate(0, 0);
    }

    10% {
        transform: scale(1.05) translate(-1%, -1%);
    }

    20% {
        transform: scale(1.05) translate(1%, 1%);
    }

    30% {
        transform: scale(1.05) translate(-1%, 1%);
    }

    40% {
        transform: scale(1.05) translate(1%, -1%);
    }

    50% {
        transform: scale(1.05) translate(-1%, 0);
    }

    60% {
        transform: scale(1.05) translate(1%, 0);
    }

    70% {
        transform: scale(1.05) translate(0, 1%);
    }

    80% {
        transform: scale(1.05) translate(0, -1%);
    }

    90% {
        transform: scale(1.05) translate(-1%, 0);
    }

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

.shake-anim {
    animation: shake-anim 0.5s ease-in-out;
    will-change: transform;
}

/* Dead End Screen */
#dead-end-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    /* Above UI (10) and Modals (100) */
    pointer-events: none;
    /* Pass events when hidden */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Align button to bottom */
    align-items: center;
}

#dead-end-overlay:not(.hidden) {
    pointer-events: auto;
    /* Catch clicks when visible */
}

#dead-end-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../Assets/Image/BackGround/デッドエンド画面/system_デッドエンド背景.png');
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 2s ease-in-out;
    z-index: 1;
}

#dead-end-retry-btn {
    opacity: 0;
    z-index: 2;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 5cqh;
    /* Bottom margin */
    cursor: pointer;
    transition: opacity 1s ease-in-out, transform 0.2s;
    width: 20cqw;
    /* Adjust size as needed */
    height: auto;
    pointer-events: none;
    /* Block clicks by default */
}

#dead-end-retry-btn.interactive {
    pointer-events: auto;
    /* Allow clicks only when interactive */
}

#dead-end-retry-btn img {
    width: 100%;
    height: auto;
}

#dead-end-retry-btn:hover {
    transform: scale(1.05);
}

/* Visibility Control Classes */
.dead-end-visible-bg #dead-end-bg {
    opacity: 1;
}

.dead-end-visible-btn #dead-end-retry-btn {
    opacity: 1;
}

/* --- Preloader --- */
#preloader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    z-index: 30000;
    /* Higher than game-start-overlay (20000) */
    display: flex;
    justify-content: center;
    /* Center dialog */
    align-items: center;
    pointer-events: auto;
    /* Allow interactions */
    transition: opacity 0.5s ease-out;
}

.preloader-modal {
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid #444;
    padding: 2cqw;
    border-radius: 8px;
    text-align: center;
    max-width: 50cqw;
    /* Slightly wider */
}

.preloader-modal h3 {
    margin-top: 0;
    color: #ffd700;
    font-size: 1.5cqw;
}

.preloader-modal p {
    font-size: 1.1cqw;
    line-height: 1.5;
    margin: 1.5cqw 0;
}

.preloader-buttons {
    display: flex;
    gap: 1.5cqw;
    justify-content: center;
    margin-top: 1cqw;
}

.preloader-buttons .sys-btn {
    width: 14cqw;
    /* Fixed equal width */
    height: 2.5cqw;
    /* Reduced from 4cqw */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    /* Let width/height handle it */
    font-size: 1cqw;
}

#loading-text {
    position: absolute;
    bottom: 0;
    right: 0;
    font-size: 2.5cqw;
    /* Doubled from 1.25cqw */
    font-family: inherit;
    margin: 2cqw;
    /* Scaled margin */
    user-select: none;
}

#preloader-cancel-container {
    position: absolute;
    top: 65%;
    /* Move entire container slightly below center */
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5cqw;
    z-index: 30001;
}

.cancel-desc {
    font-size: 0.9cqw;
    color: #ccc;
    line-height: 1.6;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.5cqw;
}

#preloader-cancel-btn {
    width: 10cqw;
    height: 2.5cqw;
    background: rgba(255, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1cqw;
}

#preloader-cancel-btn:hover {
    background: rgba(255, 0, 0, 0.4);
}

#loading-text.clickable {
    cursor: pointer;
    text-decoration: underline;
    color: #4df;
    /* Interaction hint */
    animation: blink 1.5s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}