/* style.css Kappa Theme */
body {
    margin: 0;
    background: #001a1a;
    color: #e0f5e0;
    font-family: "Hiragino Mincho ProN", "YuMincho", serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#cover {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, #052b2b 0%, #001a1a 100%);
    position: relative;
}

h1 {
    font-size: 2.9em;
    margin: 40px 0;
    color: #76c944;
    letter-spacing: 0.25em;
    text-shadow: 0 0 25px rgba(118, 201, 68, 0.5);
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 30px;
    padding: 20px;
    max-width: 1700px;
    margin: 0 auto;
}

/* Thumbnails */
.page {
    background: #0f2020;
    border: 4px double #2e4d2e;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.5s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.page:hover {
    transform: translateY(-18px) scale(1.04);
    box-shadow: 0 30px 60px rgba(68, 217, 230, 0.25);
    border-color: #44d9e6;
}

.page img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    object-position: top;
    /* ① サムネイルの表示を上部中央にする */
    opacity: 0.9;
    transition: opacity 0.3s;
}

/* ② finishボタンのオーバーレイ表示用 */
.finish-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('finish1.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.finish-overlay.show {
    opacity: 1;
}

.page:hover img {
    opacity: 1;
}

.page p {
    padding: 20px;
    margin: 0;
    font-size: 1.2em;
    background: #0a1515;
    color: #cce0cc;
    line-height: 1.7;
}

/* Book Overlay */
#book {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: flex;
    background: #051010;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
}

#book.open {
    opacity: 1;
    pointer-events: all;
}

/* Video Area */
.left-page {
    flex: 1;
    background: #020a0a;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#book-video {
    width: 100%;
    max-width: 960px;
    max-height: 82vh;
    border: 12px solid #2e4d2e;
    border-radius: 12px;
    background: #000;
    box-shadow: 0 0 50px rgba(68, 217, 230, 0.1), inset 0 0 70px rgba(0, 0, 0, 0.9);
    position: relative;
    z-index: 2;
}

/* Text Area */
/* Use a water-like pattern or simple dark green */
.right-page {
    flex: 1;
    padding: 70px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: radial-gradient(circle at 50% 50%, #0a2525 0%, #020a0a 100%);
}

.story {
    max-width: 900px;
    font-size: 2.3em;
    line-height: 2.4;
    color: #e0ffe0;
    text-shadow: 0 4px 10px #000;
    background: rgba(5, 20, 20, 0.85);
    padding: 70px 90px;
    border: 5px double #76c944;
    border-radius: 18px;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);

    flex-grow: 1;
    width: 90%;
    /* Fix width to max-width even with short text */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Control Buttons */
#close-book {
    position: absolute;
    top: 35px;
    right: 35px;
    width: 62px;
    height: 62px;
    background: #1b3333;
    color: #76c944;
    border: 5px solid #2e4d2e;
    border-radius: 50%;
    font-size: 2.8em;
    line-height: 52px;
    cursor: pointer;
    transition: all 0.4s;
    z-index: 1001;
}

#close-book:hover {
    background: #76c944;
    color: #052b2b;
    transform: rotate(180deg);
}

.turn-page {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 160px;
    background: rgba(68, 217, 230, 0.1);
    border: none;
    color: #44d9e6;
    font-size: 4.5em;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.4s;
    z-index: 1001;
}

#prev-page {
    left: 25px;
}

#next-page {
    right: 25px;
}

.turn-page:hover {
    background: rgba(68, 217, 230, 0.3);
    transform: translateY(-50%) scale(1.2);
}

#control-panel {
    margin-top: 40px;
    padding: 18px 50px;
    background: rgba(5, 25, 25, 0.95);
    border-radius: 60px;
    border: 4px solid #2e4d2e;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    display: flex;
    gap: 35px;
    align-items: center;
}

.ctrl-btn {
    background: #1b3333;
    color: #cce0cc;
    border: 3px solid #76c944;
    padding: 15px 35px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.35s;
}

.ctrl-btn:hover {
    background: #76c944;
    color: #001a1a;
}

.ctrl-btn.active {
    background: #76c944;
    color: #001a1a;
}

/* Welcome Overlay */
#welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 背景画像設定: 縦幅いっぱい(100%)に合わせて表示、余白は黒 */
    background: #000 url('title.png') no-repeat center center;
    background-size: auto 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* テキストを下寄りに配置 */
    align-items: center;
    z-index: 9999;
    color: #76c944;
    text-align: center;
    cursor: pointer;
    transition: opacity 1s ease;
    padding-bottom: 50px;
    /* 下端の余白 */
}

/* #welcome-title 削除に伴いスタイルも不要だが、HTMLから削除済みなので放置でも影響なし。念のため残すか削除するか */
/* #welcome-title { font-size: 3.2em; margin-bottom: 40px; text-shadow: 0 0 30px rgba(68,217,230,0.6); } */

#welcome-message {
    font-size: 2.4em;
    line-height: 1.6;
    text-shadow: 0 4px 10px #000, 0 0 20px rgba(0, 0, 0, 0.8);
    /* 視認性向上のためシャドウ強化 */
    color: #e0f5e0;
    background: rgba(0, 0, 0, 0.5);
    /* 背景の明暗によっては文字が見にくいので半透明黒背景を追加 */
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

#welcome-tap {
    margin-top: 10px;
    font-size: 1.4em;
    opacity: 0.9;
    color: #44d9e6;
    text-shadow: 0 2px 5px #000;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 20px;
}


/* Finish Button */
#finish-btn {
    background: #006064 !important;
    /* Cyan-ish Dark */
    border-color: #00bcd4 !important;
    animation: pulse 2s infinite;
    color: #fff;
}

#finish-btn:hover {
    background: #00bcd4 !important;
    transform: scale(1.1);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 188, 212, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(0, 188, 212, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 188, 212, 0);
    }
}

@keyframes shake {

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

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-10px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(10px);
    }
}

.story {
    transition: all 0.3s;
}

/* Water Spray Particle Effect */
.water-particle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #ffffff 30%, rgba(255, 255, 255, 0.4) 100%);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
}

@keyframes water-spray {
    0% {
        transform: translate(-50%, 0) scale(0.3);
        opacity: 0.9;
    }

    10% {
        opacity: 1;
    }

    100% {
        /* Move up and spread out based on --tx variable */
        transform: translate(calc(-50% + var(--tx)), -70vh) scale(var(--s));
        opacity: 0;
    }
}

/* Introduction Frame */
#intro-frame {
    width: 90%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    /* 正方形 */
    margin: 0 auto;
    border: 6px double #76c944;
    border-radius: 15px;
    background-color: #000;
    background-size: contain;
    /* 画像全体を表示（余白が出る可能性あり） */
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(118, 201, 68, 0.4);
    overflow: hidden;
    transition: all 0.3s;

    /* 初期状態は非表示 */
    display: none;
    opacity: 0;
    transform: scale(0.9);
}

/* 表示時のアニメーション用クラス */
#intro-frame.show {
    display: block;
    animation: fade-in-scale 0.5s forwards;
    margin-bottom: 50px;
    /* 表示時のみマージン確保 */
}

@keyframes fade-in-scale {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#intro-frame:hover {
    transform: scale(1.02);
    box-shadow: 0 0 40px rgba(68, 217, 230, 0.6);
    border-color: #44d9e6;
}

#intro-text {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 26, 26, 0.7);
    color: #e0f5e0;
    font-size: 2em;
    padding: 15px 0;
    text-align: center;
    text-shadow: 0 2px 4px #000;
    backdrop-filter: blur(4px);
    transition: color 0.3s;
    font-family: inherit;
}

#intro-frame:hover #intro-text {
    color: #44d9e6;
}

/* Footer */
footer {
    background: #000;
    color: #5a7a5a;
    text-align: center;
    padding: 20px 0;
    font-size: 0.9em;
    letter-spacing: 0.1em;
    border-top: 1px solid #1b3333;
    width: 100%;
}