/* style.css - ver 4.23.0 */

:root {
    --bg-dark: #0f0b0b;
    --box-wood: #2a1a10;
    --box-border: #8d7b68;
    --text-color: #d7ccc8;
    --accent-red: #ff3333;
    --font-serif: 'Shippori Mincho', serif;
}

* { box-sizing: border-box; user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }

html, body {
    background-color: var(--bg-dark); color: var(--text-color); font-family: var(--font-serif);
    width: 100%; height: 100dvh; overflow: hidden; position: fixed;
}

.hidden { display: none !important; }

p, div { word-break: auto-phrase; line-break: strict; overflow-wrap: break-word; }

/* UI Loading/Title */
#loading-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 5000; display: flex; justify-content: center; align-items: center; color: #fff; transition: opacity 0.5s; }
.loading-bar { width: 200px; height: 4px; background: #333; border-radius: 2px; margin-top: 10px; overflow: hidden; }
#loading-progress { width: 0%; height: 100%; background: #ff3333; transition: width 0.2s; }

@keyframes curse-glitch {
    0%, 94%, 100% { filter: drop-shadow(0 0 10px rgba(255,0,0,0.5)) hue-rotate(0deg); transform: translate(0, 0) skew(0deg); }
    95% { filter: drop-shadow(0 0 20px rgba(255,0,0,1)) hue-rotate(90deg); transform: translate(2px, 2px) skew(5deg); }
    97% { filter: drop-shadow(0 0 15px rgba(255,0,0,0.8)) hue-rotate(-90deg); transform: translate(-2px, -2px) skew(-5deg); }
}

.severe-glitch { animation: severe-glitch-anim 0.2s steps(2) 3 !important; }
@keyframes severe-glitch-anim {
    0% { transform: translate(0) skew(0deg); filter: drop-shadow(0 0 10px rgba(255,0,0,0.5)) hue-rotate(0deg); }
    20% { transform: translate(-15px, 10px) skew(-30deg); filter: drop-shadow(0 0 30px rgba(255,0,0,1)) hue-rotate(180deg) invert(1); }
    40% { transform: translate(15px, -10px) skew(30deg); filter: drop-shadow(0 0 5px rgba(255,0,0,0.8)) hue-rotate(-90deg); }
    60% { transform: translate(-10px, -15px) skew(-15deg); filter: drop-shadow(0 0 40px rgba(255,0,0,1)) blur(3px); }
    80% { transform: translate(10px, 15px) skew(15deg); filter: drop-shadow(0 0 15px rgba(255,0,0,0.5)) hue-rotate(270deg); }
    100% { transform: translate(0) skew(0deg); filter: drop-shadow(0 0 10px rgba(255,0,0,0.5)) hue-rotate(0deg); }
}

#title-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 4000; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
#title-background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; background-image: url('assets/title_bg.png'); background-size: cover; background-position: center; filter: brightness(0.4); }

#title-easter-eggs { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 0; }
#title-hexagram { position: absolute; top: 50%; left: 50%; width: 400px; height: 400px; transform: translate(-50%, -50%); opacity: 0; transition: opacity 1s; }
#title-hexagram.active { opacity: 0.15; animation: title-hex-spin 12s linear forwards; }
@keyframes title-hex-spin { 
    0% { transform: translate(-50%, -50%) rotate(0deg) scale(0.6); } 
    50% { opacity: 0.25; }
    100% { transform: translate(-50%, -50%) rotate(360deg) scale(1.5); opacity: 0; } 
}
#title-floating-item { position: absolute; width: 200px; height: 200px; object-fit: contain; opacity: 0; filter: drop-shadow(0 0 15px rgba(255,0,0,0.8)) blur(1px) brightness(0.4); }
#title-floating-item.active { animation: float-up-fade 8s ease-in-out forwards; }
@keyframes float-up-fade { 
    0% { opacity: 0; transform: translateY(80px) scale(0.8) rotate(-10deg); } 
    50% { opacity: 0.5; } 
    100% { opacity: 0; transform: translateY(-80px) scale(1.2) rotate(10deg); } 
}
.title-content { position: relative; z-index: 10; }

#title-logo { width: 80%; max-width: 400px; margin-bottom: 40px; animation: curse-glitch 4s infinite; }
.menu-btn { background: rgba(0, 0, 0, 0.8); border: 1px solid #8d7b68; color: #d7ccc8; font-family: var(--font-serif); font-size: 1.5rem; padding: 12px 40px; width: 240px; margin-bottom: 15px; cursor: pointer; border-radius: 4px; transition: 0.3s; }
.menu-btn:hover { background: rgba(255, 50, 50, 0.2); border-color: var(--accent-red); color: var(--accent-red); letter-spacing: 0.1em; box-shadow: 0 0 15px rgba(255, 0, 0, 0.3); }
.menu-btn.disabled { color: #444; border-color: #333; cursor: not-allowed; background: rgba(0,0,0,0.4); }
.version { position: absolute; bottom: 10px; right: 10px; font-size: 0.8rem; color: #666; }

/* Credits Screen */
#credits-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 5000; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.credits-content { background: #1a0f0f; border: 2px solid var(--box-border); padding: 40px; border-radius: 8px; width: 90%; max-width: 500px; text-align: center; box-shadow: 0 0 30px #000; }
.credits-title { color: var(--accent-red); margin-bottom: 30px; letter-spacing: 0.2em; border-bottom: 1px solid #4a2a2a; padding-bottom: 10px; font-size: 1.8rem; }
.credits-text p { color: #ccc; margin-bottom: 25px; font-size: 1.1rem; line-height: 1.6; }
.credits-text strong { color: #ff3333; font-size: 0.9rem; letter-spacing: 0.1em; display: inline-block; margin-bottom: 5px; }

/* Caution Screen */
#caution-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 4200; display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.5s ease, visibility 0.5s; }
#caution-screen.active { opacity: 1; visibility: visible; pointer-events: auto; }
.caution-content { background: transparent; padding: 40px; border: 1px solid rgba(255, 51, 51, 0.5); border-radius: 4px; max-width: 80%; text-align: center; box-shadow: 0 0 20px rgba(255,0,0,0.1); }
.caution-title { color: var(--accent-red); font-size: 2rem; margin-bottom: 20px; letter-spacing: 0.2em; text-shadow: 0 0 10px rgba(255,0,0,0.5); }
.caution-text { color: #ccc; font-size: 1.1rem; line-height: 2.0; }

/* Prologue Screen */
#prologue-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 4100; display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 1.0s ease, visibility 1.0s; }
#prologue-screen.active { opacity: 1; visibility: visible; pointer-events: auto; }
#prologue-background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; background-image: url('assets/prologue_bg.png'); background-size: cover; background-position: center; filter: brightness(0.3) sepia(0.2); }
#prologue-text-container { background: rgba(0, 0, 0, 0.7); padding: 40px; border-radius: 8px; max-width: 80%; text-align: left; box-shadow: 0 0 40px rgba(0,0,0,0.8); }
#prologue-text { color: #e0e0e0; font-size: 1.1rem; line-height: 2.2; white-space: pre-wrap; }
.click-to-continue { text-align: center; color: #888; font-size: 0.9rem; margin-top: 30px; animation: blink 3s infinite; }

/* Collection Screen */
#collection-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #0f0b0b; z-index: 4500; padding: 20px; overflow-y: auto; text-align: center; display: flex; flex-direction: column; }
#collection-screen h2 { margin-top: 30px; margin-bottom: 10px; color: var(--accent-red); }
#collection-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; align-content: center; margin: 0 auto 40px auto; max-width: 700px; flex: 1; }
.collection-item { width: 100px; height: 100px; background: #1a1a1a; border: 1px solid #333; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; }
.collection-item:hover { border-color: var(--accent-red); box-shadow: 0 0 10px rgba(255,0,0,0.5); }
.collection-item img { max-width: 90%; max-height: 90%; }
.collection-item.locked { filter: brightness(0.2); pointer-events: none; }
.back-btn { padding: 10px 30px; background: transparent; border: 1px solid #888; color: #ddd; font-family: var(--font-serif); font-size: 1.2rem; cursor: pointer; transition: 0.3s; margin: 0 auto 20px auto; display: block; width: fit-content; min-width: 150px;}

/* Detail Overlay & Nightmare */
#collection-detail-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 5000; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.detail-box { width: 90%; max-width: 450px; background: #1a0f0f; border: 2px solid var(--box-border); padding: 25px; border-radius: 8px; text-align: center; box-shadow: 0 0 30px #000; display: flex; flex-direction: column; align-items: center; max-height: 90vh; overflow-y: auto; }
#detail-name { color: var(--accent-red); font-size: 1.8rem; border-bottom: 1px solid #4a2a2a; padding-bottom: 10px; width: 100%; margin-bottom: 20px; }
.detail-content { display: flex; width: 100%; gap: 20px; margin-bottom: 15px; align-items: flex-start; }
.detail-image-box { width: 120px; height: 120px; flex-shrink: 0; background: #000; border: 1px solid #4a2a2a; display: flex; justify-content: center; align-items: center; box-shadow: inset 0 0 20px rgba(255,0,0,0.1); }
#detail-image { width: 80px; height: 80px; image-rendering: pixelated; transform: scale(1.4); filter: drop-shadow(0 0 5px #000); }
.detail-info { flex: 1; text-align: left; display: flex; flex-direction: column; }
#detail-danger { font-size: 1.1rem; margin-bottom: 10px; color: #aaa; }
.detail-desc-header { font-size: 0.9rem; color: #666; margin-bottom: 5px; }
.detail-desc-box { background: rgba(0,0,0,0.3); padding: 10px; border-radius: 4px; flex: 1; border: 1px solid #333; }
#detail-description { font-size: 0.9rem; line-height: 1.6; color: #ccc; white-space: pre-wrap; }

.detail-nightmare-header { font-size: 0.9rem; color: #666; margin-bottom: 5px; width: 100%; text-align: left; border-top: 1px solid #333; padding-top: 15px; }
#detail-nightmare-container { width: 100%; background: #0b0707; border: 1px solid #333; border-radius: 4px; margin-bottom: 20px; text-align: center; }
#detail-nightmare-img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 3px; display: block; filter: grayscale(0.2) sepia(0.2); }
#detail-nightmare-locked { color: #555; font-size: 0.9rem; letter-spacing: 0.2em; padding: 40px 0; }

/* Game UI Header */
#game-container { display: flex; flex-direction: column; width: 100%; height: 100%; }
#ui-header { height: 60px; background: #1a0f0f; border-bottom: 2px solid #4a2a2a; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; z-index: 100; flex-shrink: 0; position: relative; }
#game-logo { position: absolute; left: 50%; transform: translateX(-50%); display: flex; justify-content: center; align-items: center; pointer-events: none; margin: 0; }
#game-logo img { height: 35px; }
#day-counter-area { display: flex; align-items: center; gap: 15px; flex: 1; justify-content: flex-start; }
#day-counter { font-size: 1.2rem; font-weight: bold; }
#debug-controls { display: flex; gap: 5px; pointer-events: auto; }
.debug-btn { background: #555; color: #fff; border: 1px solid #777; padding: 2px 8px; font-weight: bold; cursor: pointer; border-radius: 3px; font-family: sans-serif; transition: 0.2s; }
.debug-btn:hover { background: #777; }
#header-controls { display: flex; gap: 15px; align-items: center; flex: 1; justify-content: flex-end; }
#current-item-name { font-size: 1.1rem; color: var(--accent-red); font-weight: bold; text-align: right; letter-spacing: 0.1em; }
.sys-btn { cursor: pointer; font-size: 1.5rem; user-select: none; transition: 0.2s; }
.sys-btn:hover { filter: brightness(1.2) drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
#san-container { font-size: 1.1rem; margin-right: 5px; }

/* ダメージを受けた時のSAN値シェイクアニメーション */
.shake-san {
    animation: san-shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    color: #ff0000 !important;
    text-shadow: 0 0 10px #ff0000;
}
@keyframes san-shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Options Modal */
#options-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 6000; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.options-content { background: #1a0f0f; border: 2px solid var(--box-border); padding: 25px 30px; border-radius: 8px; width: 90%; max-width: 400px; text-align: center; box-shadow: 0 0 30px #000; max-height: 95vh; overflow-y: auto;}
.options-title { color: var(--accent-red); margin-bottom: 15px; letter-spacing: 0.2em; border-bottom: 1px solid #4a2a2a; padding-bottom: 10px; }
.option-row { margin: 15px 0; display: flex; flex-direction: column; align-items: center; gap: 5px; color: #ccc; }
.option-row label { display: flex; justify-content: space-between; width: 80%; font-size: 1rem;}
.option-row label span { color: #fff; font-weight: bold; }
.option-row input { width: 80%; cursor: pointer; }

.option-buttons { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 25px; border-top: 1px solid #333; padding-top: 20px;}
.option-buttons .menu-btn { width: 90%; font-size: 1.1rem; padding: 10px; margin-bottom: 0; }
.danger-btn { border-color: #8b0000; color: #ff6666; }
.danger-btn:hover { background: rgba(139, 0, 0, 0.3); border-color: #ff3333; color: #ff3333; }

/* SAN値による視覚エフェクト */
#play-area { flex: 1; position: relative; background: #111; display: flex; justify-content: center; align-items: center; overflow: hidden; transition: box-shadow 1s ease, background-color 1s ease; }
.san-low #play-area { box-shadow: inset 0 0 50px rgba(150, 0, 0, 0.3); }
.san-critical #play-area { box-shadow: inset 0 0 100px rgba(200, 0, 0, 0.5); animation: san-pulse 2s infinite alternate ease-in-out; }
@keyframes san-pulse {
    0% { box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.4); background-color: #111; }
    100% { box-shadow: inset 0 0 140px rgba(255, 0, 0, 0.7); background-color: #1a0505; }
}

/* Box System */
#grid-container { position: relative; background: var(--box-wood); border: 5px solid var(--box-border); z-index: 10; box-shadow: 0 20px 50px #000; transition: transform 0.5s; box-sizing: content-box; overflow: visible; }
#sealed-items-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 50; pointer-events: none; }
.box-lid { position: absolute; top: 0; width: 50%; height: 100%; background: #3e2723; background-image: repeating-linear-gradient(45deg, #3e2723 0, #3e2723 10px, #2d1b15 10px, #2d1b15 20px); z-index: 100; transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1); box-shadow: inset 0 0 20px #000; }
#box-lid-left { left: 0; transform: translateX(-101%); border-right: 2px solid #1a0f0f; }
#box-lid-right { right: 0; transform: translateX(101%); border-left: 2px solid #1a0f0f; }
#grid-container.sealing .box-lid { transform: translateX(0); }

/* Hexagram */
#hexagram { position: absolute; top: 50%; left: 50%; width: 250px; height: 250px; transform: translate(-50%, -50%) scale(0); z-index: 200; pointer-events: none; opacity: 0; display: flex; justify-content: center; align-items: center; transition: opacity 0.5s; }
#hexagram.active { opacity: 1; animation: spawn-spin 4s forwards linear; }
.hex-circle { position: absolute; width: 100%; height: 100%; border: 4px solid var(--accent-red); border-radius: 50%; box-shadow: 0 0 15px var(--accent-red), inset 0 0 15px var(--accent-red); }
.hex-tri-1 { position: absolute; width: 0; height: 0; border-left: 108px solid transparent; border-right: 108px solid transparent; border-bottom: 187px solid var(--accent-red); filter: drop-shadow(0 0 10px var(--accent-red)); transform: translateY(-15%); }
.hex-tri-1::after { content: ""; position: absolute; top: 6px; left: -100px; border-left: 100px solid transparent; border-right: 100px solid transparent; border-bottom: 173px solid var(--bg-dark); }
.hex-tri-2 { position: absolute; width: 0; height: 0; border-left: 108px solid transparent; border-right: 108px solid transparent; border-top: 187px solid var(--accent-red); filter: drop-shadow(0 0 10px var(--accent-red)); transform: translateY(15%); }
@keyframes spawn-spin { 0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; } 10% { transform: translate(-50%, -50%) scale(1.2) rotate(60deg); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1) rotate(360deg); opacity: 1; filter: brightness(1.5); } }
#grid-frame { box-sizing: content-box; border: 2px solid #332015; background: #2a1a10; z-index: 1; }
#grid { position: relative; background-image: linear-gradient(rgba(0,0,0,0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.3) 1px, transparent 1px); }

/* Obstacles */
.obstacle-cell { position: absolute; background-color: rgba(30, 10, 10, 0.8); box-shadow: inset 0 0 15px #000; pointer-events: none; border: 1px solid rgba(0,0,0,0.5); z-index: 5; }
.obstacle-cell::before { content: ""; position: absolute; top: 5%; left: 5%; right: 5%; bottom: 5%; background: radial-gradient(circle, rgba(150,0,0,0.5) 0%, transparent 70%); border-radius: 50%; filter: blur(3px); }

/* Items & Danger Levels */
#items-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 20; pointer-events: auto; }
.cursed-item { position: absolute; pointer-events: auto; filter: drop-shadow(2px 5px 5px rgba(0,0,0,0.8)); transition: transform 0.1s; }

/* 異常呪物（黒い煙）の強化エフェクト */
.anomaly-item::after {
    content: "";
    position: absolute;
    top: -20px; left: -20px; right: -20px; bottom: -20px;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.7) 0%, rgba(150, 0, 0, 0.4) 50%, transparent 70%);
    filter: blur(10px);
    z-index: 5;
    pointer-events: none;
    animation: anomaly-smoke 1.5s infinite alternate ease-in-out;
}
@keyframes anomaly-smoke {
    0% { transform: scale(0.9) rotate(-2deg) translateY(2px); opacity: 0.7; filter: blur(8px); }
    100% { transform: scale(1.1) rotate(2deg) translateY(-2px); opacity: 1; filter: blur(12px); }
}
.anomaly-item .item-texture {
    filter: drop-shadow(0 0 10px rgba(255, 30, 30, 0.8)) brightness(0.75) contrast(1.3) sepia(0.3) hue-rotate(-20deg) saturate(1.5) !important;
}

.item-block { position: absolute; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,0,0,0.1); border-radius: 2px; }
.cursed-item.in-grid .item-block { background-color: rgba(150, 0, 0, 0.25); box-shadow: inset 0 0 10px rgba(50, 0, 0, 0.5); }
@keyframes pulse-border-dark { 0% { border-color: rgba(200, 0, 0, 0.3); box-shadow: inset 0 0 5px rgba(255, 0, 0, 0.1); } 100% { border-color: rgba(255, 0, 0, 0.8); box-shadow: inset 0 0 15px rgba(255, 0, 0, 0.6), 0 0 5px rgba(255, 0, 0, 0.5); } }
.danger-1 .item-block { border-color: rgba(100, 100, 100, 0.1); }
.danger-2 .item-block { border-color: rgba(100, 50, 30, 0.15); }
.danger-3 .item-block { border-color: rgba(100, 0, 0, 0.25); background-color: rgba(50, 0, 0, 0.05); }
.danger-4 .item-block { border: 1px solid rgba(200, 0, 0, 0.3); animation: pulse-border-dark 2s infinite alternate; }
.danger-5 .item-block { border: 1px solid rgba(255, 0, 0, 0.8); background-color: rgba(150, 0, 0, 0.3); animation: pulse-border-dark 0.8s infinite alternate; box-shadow: inset 0 0 20px rgba(255,0,0,0.8); }
.item-texture { position: absolute; pointer-events: none; filter: drop-shadow(0 0 3px #000); transform-origin: center center; }

@keyframes burn-purple { 0% { filter: brightness(1) sepia(0); transform: scale(1); opacity: 1; } 30% { filter: brightness(1.3) sepia(1) hue-rotate(220deg) saturate(3) drop-shadow(0 0 15px #b000ff); transform: scale(1.05) translate(1px, -1px); } 100% { filter: brightness(0) grayscale(1) drop-shadow(0 0 30px #4b0082); opacity: 0; transform: scale(0.9) translateY(-40px); } }
.purged-item { animation: burn-purple 2s forwards ease-in-out; pointer-events: none; z-index: 300; }

#ui-footer { height: 80px; background: #1a0f0f; border-top: 2px solid #4a2a2a; display: flex; justify-content: center; align-items: center; z-index: 100; flex-shrink: 0; }
#seal-button { background: #8b0000; color: #fff; border: 2px solid #ff3333; padding: 15px 0; width: 80%; max-width: 300px; font-size: 1.5rem; font-family: var(--font-serif); font-weight: bold; border-radius: 5px; cursor: pointer; transition: 0.2s;}
#seal-button:active { background: #5d0000; transform: translateY(2px); }

/* --- Overlays --- */
#nightmare-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 3000; display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 1.5s ease-in-out, visibility 1.5s; }
#nightmare-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }
#nightmare-intro { color: #fff; font-size: 1.5rem; letter-spacing: 0.2em; text-shadow: 0 0 10px rgba(255,255,255,0.5); opacity: 0; visibility: hidden; position: absolute; transition: opacity 1.5s ease, visibility 1.5s; }
#nightmare-intro.active { opacity: 1; visibility: visible; }
#nightmare-content { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; visibility: hidden; position: relative; transition: opacity 1.5s ease, visibility 1.5s; }
#nightmare-content.active { opacity: 1; visibility: visible; }
#nightmare-image { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0.8; pointer-events: none; filter: grayscale(0.3) contrast(1.2) sepia(0.2); }
#nightmare-text-container { position: relative; z-index: 10; background: rgba(0, 0, 0, 0.7); padding: 30px; border: 1px solid #500; border-radius: 5px; max-width: 85%; box-shadow: 0 0 30px rgba(50, 0, 0, 0.8); }
#nightmare-text { color: #ff3333; font-size: 1.2rem; text-shadow: 0 0 10px #000; text-align: center; white-space: pre-wrap; line-height: 2; font-weight: bold; }
.click-to-close { position: absolute; bottom: 30px; color: #888; font-size: 0.9rem; z-index: 10; animation: blink 3s infinite; opacity: 0; transition: opacity 1s; }
#nightmare-content.active .click-to-close { opacity: 1; transition-delay: 1.5s; }
@keyframes blink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

#dialogue-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 20px; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.5s, visibility 0.5s; }
#dialogue-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }

/* エンディング時の背景切り替え用クラス */
#dialogue-overlay.ending-bg {
    background-image: url('assets/prologue_bg.png');
    background-size: cover;
    background-position: center;
    background-color: #000;
}
#dialogue-overlay.ending-bg::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: -1;
}

#zakuro-img { max-height: 60vh; max-width: 90%; margin-bottom: -10px; }
#dialogue-box { width: 90%; max-width: 600px; background: rgba(0,0,0,0.9); border: 2px solid var(--box-border); padding: 20px; border-radius: 5px; position: relative; min-height: 140px; display: flex; flex-direction: column; }
#speaker-name { color: #ff4d4d; font-weight: bold; font-size: 1.1rem; margin-bottom: 10px; border-bottom: 1px solid #555; display: inline-block; width: fit-content; }
#dialogue-text { color: #fff; font-size: 1.1rem; line-height: 1.6; flex-grow: 1;}
#dialogue-next { position: absolute; bottom: 10px; right: 20px; color: #ff4d4d; animation: blink 1s infinite; }

#message-area { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.8); border: 1px solid #ff3333; color: #fff; padding: 15px 30px; border-radius: 5px; z-index: 4000; font-size: 1.2rem; opacity: 0; transition: opacity 0.5s; pointer-events: none;}
#message-area.active { opacity: 1; }

/* エピローグ画面 */
#epilogue-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 4800; display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 1.0s ease, visibility 1.0s; }
#epilogue-screen.active { opacity: 1; visibility: visible; pointer-events: auto; }
.epilogue-content { text-align: center; }
.epilogue-text { color: #ccc; font-size: 1.2rem; line-height: 2.2; margin-bottom: 40px; text-shadow: 0 0 10px rgba(255,255,255,0.2); }

/* Clear Screen */
#clear-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #050000; z-index: 5000; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.clear-content { background: #1a0f0f; border: 2px solid var(--box-border); padding: 40px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 0 40px rgba(255,0,0,0.1); }
.clear-title { color: var(--accent-red); font-size: 2.2rem; margin-bottom: 20px; letter-spacing: 0.2em; text-shadow: 0 0 15px rgba(255,0,0,0.5); }
.clear-text { color: #ccc; font-size: 1.1rem; line-height: 1.8; margin-bottom: 20px; }
.san-result { font-size: 1.5rem; color: #aaa; margin-bottom: 30px; border-top: 1px solid #4a2a2a; border-bottom: 1px solid #4a2a2a; padding: 20px 0; }
.san-result span { font-size: 3rem; color: var(--accent-red); font-weight: bold; margin-left: 15px; text-shadow: 0 0 10px rgba(255,0,0,0.5); }
.clear-buttons { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.share-btn { background: #0f1419; color: #fff; border: 1px solid #333; font-family: sans-serif; font-weight: bold;}
.share-btn:hover { background: #272c30; border-color: #555; box-shadow: none; color: #fff; letter-spacing: normal; }

/* Game Over Screen */
#gameover-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #050000; z-index: 5000; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.gameover-content { background: #110000; border: 2px solid #8b0000; padding: 40px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 0 40px rgba(255,0,0,0.3); animation: san-shake 0.5s ease-in-out; }
.gameover-title { color: #ff0000; font-size: 2.5rem; margin-bottom: 20px; letter-spacing: 0.3em; text-shadow: 0 0 20px #ff0000; animation: severe-glitch-anim 2s infinite alternate; }
.gameover-text { color: #ccc; font-size: 1.1rem; line-height: 1.8; margin-bottom: 20px; }
.result-stats { font-size: 1.5rem; color: #aaa; margin-bottom: 30px; border-top: 1px solid #4a0000; border-bottom: 1px solid #4a0000; padding: 20px 0; }
.result-stats span { font-size: 3rem; color: #ff3333; font-weight: bold; margin: 0 10px; text-shadow: 0 0 10px rgba(255,0,0,0.5); }

/* Mobile Optimization */
@media (max-width: 600px) {
    #game-logo img { height: 25px; }
    #day-counter-area { gap: 5px; }
    #day-counter { font-size: 1rem; }
    #header-controls { gap: 10px; }
    #current-item-name { font-size: 0.9rem; min-width: 0; }
    .sys-btn { font-size: 1.2rem; }
    #san-container { font-size: 1rem; margin-right: 0px; }
    #hexagram { width: 180px; height: 180px; }
    .hex-tri-1 { border-left-width: 78px; border-right-width: 78px; border-bottom-width: 135px; }
    .hex-tri-1::after { top: 4px; left: -72px; border-left-width: 72px; border-right-width: 72px; border-bottom-width: 125px; }
    .hex-tri-2 { border-left-width: 78px; border-right-width: 78px; border-top-width: 135px; }
    .collection-item { width: 80px; height: 80px; }
    .detail-content { flex-direction: column; align-items: center; }
    .detail-info { text-align: center; width: 100%; }
    .detail-desc-box { height: 120px; overflow-y: auto; text-align: left; }
    #nightmare-text-container { padding: 15px; width: 95%; }
    #nightmare-text { font-size: 1rem; }
    #nightmare-image { object-fit: cover; object-position: center; height: 60vh; top: 20vh; opacity: 0.6; mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%); -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%); }
    #zakuro-img { max-height: 50vh; }
    #dialogue-box { padding: 15px; min-height: 150px; }
    #dialogue-text { font-size: 1rem; }
    #prologue-text-container { padding: 25px; width: 90%; }
    #prologue-text { font-size: 1rem; line-height: 1.8; }
    .caution-content { padding: 20px; width: 95%; }
    .caution-title { font-size: 1.5rem; }
    .caution-text { font-size: 0.9rem; line-height: 1.8; }
    .clear-content { padding: 20px; width: 95%; }
    .clear-title { font-size: 1.8rem; }
    .san-result span { font-size: 2.5rem; }
    .epilogue-text { font-size: 1rem; }
    .gameover-content { padding: 20px; width: 95%; }
    .gameover-title { font-size: 2rem; }
    .result-stats span { font-size: 2.5rem; }
}