/* ===== リセット & ベース ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
}

/* ===== リーダー全体 ===== */
.picture-book-reader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: black;
    overflow: hidden;
}

/* ===== スタート画面 ===== */
.start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.start-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.start-background-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 60px;
}

.start-title {
    color: white;
    font-size: 48px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    font-weight: bold;
    text-align: center;
    padding: 0 20px;
}

.btn-start {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.btn-start:hover  { transform: scale(1.1); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); }
.btn-start:active { transform: scale(0.95); }

.start-icon {
    font-size: 50px;
    margin-left: 8px;
}

/* ===== ローディング ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    z-index: 9999;
}

/* ===== 絵本コンテナ ===== */
.book-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: black;
}

/* ===== ページ表示エリア ===== */
.page-display {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.page-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.background-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ===== インタラクティブ要素（共通） ===== */
.interactive-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.interactive-item {
    position: absolute;
    cursor: pointer;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.interactive-item:hover { opacity: 0.7; }

.interactive-item img {
    max-width: 150px;
    height: auto;
    display: block;
    pointer-events: none;
}

.interactive-item.revealed {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

.interactive-item.revealed img { filter: none; }

/* ===== クリック時アニメーション（共通） ===== */
@keyframes clickFadeIn {
    0%   { transform: translate(-50%, -50%) scale(1);    }
    50%  { transform: translate(-50%, -50%) scale(1.15); }
    100% { transform: translate(-50%, -50%) scale(1);    }
}

@keyframes clickSlideUp {
    0%   { transform: translate(-50%, -50%) translateY(0)     scale(1);    }
    50%  { transform: translate(-50%, -50%) translateY(-40px) scale(1.15); }
    100% { transform: translate(-50%, -50%) translateY(0)     scale(1);    }
}

@keyframes clickSlideDown {
    0%   { transform: translate(-50%, -50%) translateY(0)    scale(1);    }
    50%  { transform: translate(-50%, -50%) translateY(40px) scale(1.15); }
    100% { transform: translate(-50%, -50%) translateY(0)    scale(1);    }
}

@keyframes clickScale {
    0%   { transform: translate(-50%, -50%) scale(1);   }
    30%  { transform: translate(-50%, -50%) scale(0.5); }
    70%  { transform: translate(-50%, -50%) scale(1.4); }
    100% { transform: translate(-50%, -50%) scale(1);   }
}

@keyframes clickBounce {
    0%   { transform: translate(-50%, -50%) scale(1);    }
    20%  { transform: translate(-50%, -50%) scale(1.4);  }
    40%  { transform: translate(-50%, -50%) scale(0.8);  }
    60%  { transform: translate(-50%, -50%) scale(1.2);  }
    80%  { transform: translate(-50%, -50%) scale(0.95); }
    100% { transform: translate(-50%, -50%) scale(1);    }
}

.interactive-item.revealed.first-click.anim-fade       { animation: clickFadeIn   0.7s ease; }
.interactive-item.revealed.first-click.anim-slide-up   { animation: clickSlideUp  0.7s ease; }
.interactive-item.revealed.first-click.anim-slide-down { animation: clickSlideDown 0.7s ease; }
.interactive-item.revealed.first-click.anim-scale      { animation: clickScale    0.7s ease; }
.interactive-item.revealed.first-click.anim-bounce     { animation: clickBounce   0.9s ease; }

.interactive-item.revealed.repeat-click.anim-fade       { animation: clickFadeIn   0.7s ease; }
.interactive-item.revealed.repeat-click.anim-slide-up   { animation: clickSlideUp  0.7s ease; }
.interactive-item.revealed.repeat-click.anim-slide-down { animation: clickSlideDown 0.7s ease; }
.interactive-item.revealed.repeat-click.anim-scale      { animation: clickScale    0.7s ease; }
.interactive-item.revealed.repeat-click.anim-bounce     { animation: clickBounce   0.9s ease; }

/* ===== 字幕（共通） ===== */
.subtitle-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    padding: 30px 20px 20px;
    z-index: 20;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subtitle-text {
    margin: 0;
    color: white;
    line-height: 1.6;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    max-width: 90%;
}

.subtitle-container:has(.subtitle-text:empty) { display: none; }

/* ===== 進捗バッジ（共通） ===== */
.progress-badge {
    position: absolute;
    bottom: 90px;
    right: 20px;
    border-radius: 16px;
    padding: 10px 16px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    animation: slideInRight 0.4s ease;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0);    }
}

.progress-text  { color: white; font-weight: bold; white-space: nowrap; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); }
.progress-stars { letter-spacing: 2px; }

/* ===== コントロールバー（共通） ===== */
.controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    width: 90%;
    max-width: 600px;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px 20px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.btn-play-pause {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #333;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-play-pause:hover { transform: scale(1.1); }

.audio-progress {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.audio-progress-bar {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.1s linear;
}

/* ===== 音量コントロール（共通） ===== */
.volume-control {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-volume {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-volume:hover { background: rgba(255, 255, 255, 0.3); }

.volume-slider-popup {
    position: absolute;
    bottom: 65px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 10px 20px;
    border-radius: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.volume-control:hover .volume-slider-popup,
.volume-slider-popup:hover {
    opacity: 1;
    visibility: visible;
}

.volume-range {
    -webkit-appearance: slider-vertical;
    writing-mode: bt-lr;
    width: 8px;
    height: 100px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}

.volume-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
}

@-moz-document url-prefix() {
    .volume-range {
        width: 100px;
        height: 8px;
        transform: rotate(-90deg);
        transform-origin: center;
        margin: 50px 0;
    }
}

/* ===== 右上ボタン群 ===== */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 40;
}

.btn-toggle-fullscreen,
.btn-restart {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.btn-toggle-fullscreen:hover,
.btn-restart:hover {
    background: rgba(0, 0, 0, 0.65);
    border-color: white;
}

/* ===== 確認モーダル ===== */
.confirm-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    backdrop-filter: blur(4px);
}

.confirm-box {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 36px 40px;
    text-align: center;
    animation: fadeInUp 0.3s ease;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.confirm-message {
    color: white;
    font-size: 20px;
    margin-bottom: 28px;
    letter-spacing: 0.05em;
}

.confirm-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-confirm-yes,
.btn-confirm-no,
.btn-confirm-back {
    padding: 12px 32px;
    border-radius: 24px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.05em;
    border: none;
}

.btn-confirm-yes {
    background: white;
    color: #333;
}

.btn-confirm-yes:hover { background: #f0f0f0; transform: scale(1.05); }

.btn-confirm-no {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.btn-confirm-no:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.btn-confirm-back {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-confirm-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

/* ===== 終了画面（共通） ===== */
.ending-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.ending-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.ending-message {
    color: white;
    font-weight: bold;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.btn-replay {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #333;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.btn-replay:hover  { transform: scale(1.1); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.btn-replay:active { transform: scale(0.95); }

/* ===== 戻るリンク ===== */
.btn-back {
    display: inline-block;
    color: white;
    font-size: 16px;
    text-decoration: none;
    letter-spacing: 0.05em;
    padding: 10px 28px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.3s;
    backdrop-filter: blur(4px);
}

.btn-back:hover {
    color: white;
    border-color: white;
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* ===== レスポンシブ（共通） ===== */
@media (max-width: 768px) {
    .start-title { font-size: 32px; }
    .btn-start   { width: 100px; height: 100px; }
    .start-icon  { font-size: 40px; }
    .interactive-item img { max-width: 100px; }
    .subtitle-container { padding: 20px 15px 15px; min-height: 60px; bottom: 100px; }
    .controls { width: 95%; }
    .progress-badge { right: 10px; bottom: 100px; padding: 8px 12px; }
    .progress-text  { font-size: 12px; }
    .progress-stars { font-size: 14px; }
    .btn-toggle-fullscreen,
    .btn-restart     { font-size: 12px; padding: 7px 13px; }
    .confirm-box     { padding: 28px 24px; margin: 0 20px; }
    .confirm-message { font-size: 18px; }
    .btn-confirm-yes,
    .btn-confirm-no,
    .btn-confirm-back { padding: 10px 20px; font-size: 14px; }
    .btn-replay      { width: 130px; height: 130px; }
    .btn-back        { font-size: 14px; padding: 9px 22px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    .subtitle-container { min-height: 50px; padding: 15px 10px 10px; bottom: 80px; }
    .controls           { bottom: 10px; }
}