body {
    margin: 0; padding: 0;
    /* 背景画像は viewer.js の resolveAssetUrl('back_color.webp') で環境に応じて動的に設定 */
    background-color: #121214;
    background-repeat: repeat;
    background-size: 1728px auto;
    /* 【修正】hiddenだとstickyが破壊されるためclipに変更 */
    overflow-x: clip;
}

/* ページ全体のスクロールバー領域を常に表示させる */
html {
    overflow-y: scroll;
}

.manga-container {
    max-width: 520px;
    margin: 0 auto;
    background-color: black;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    padding-bottom: 80px;
    position: relative;
}

.manga-container img {
    width: 100%; height: auto; display: block;
    margin: 0; padding: 0; background-color: #000;
}

.sequence-container {
    position: relative;
    width: 100%;
    background-color: #000;
    box-sizing: border-box;
}

.canvas-sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    z-index: 2;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.h-scroll-wrapper { position: relative; width: 100%; background-color: #000; }
.h-scroll-inner { position: -webkit-sticky; position: sticky; top: 0; left: 0; width: 100%; height: 100vh; overflow: hidden; z-index: 2; }
.h-scroll-track { display: flex; height: 100%; width: max-content; }
.h-scroll-track.to-left,
.h-scroll-wrapper.to-left .h-scroll-track { flex-direction: row-reverse; }
.h-scroll-track img { width: 100vw; max-width: 520px; height: 100%; object-fit: contain; flex-shrink: 0; }

/* ▼▼ 冒頭へボタン ▼▼ */
.btn-to-top {
    position: fixed;
    right: max(16px, calc((100vw - 520px) / 2 + 16px));
    bottom: 24px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(160, 160, 165, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none; color: #ffffff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 99; user-select: none;
    transform: translateY(80px); opacity: 0; pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}

.btn-to-top.active { transform: translateY(0); opacity: 1; pointer-events: auto; }
body.toolbar-active .btn-to-top { transform: translateY(80px) !important; opacity: 0 !important; pointer-events: none !important; }
.btn-to-top svg { width: 20px; height: 20px; stroke: #ffffff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; margin-top: 2px; }
.btn-to-top span { font-size: 9.5px; font-weight: 600; color: #ffffff; letter-spacing: -0.2px; margin-top: 1px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }

/* ▼▼ ボトムツールバー用CSS ▼▼ */
.bottom-toolbar {
    position: fixed; bottom: 0; left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%; max-width: 520px;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.75) 60%, rgba(0,0,0,0) 100%);
    padding: 24px 14px 16px; box-sizing: border-box;
    display: flex; justify-content: space-between; align-items: flex-end;
    z-index: 100; pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bottom-toolbar.active { transform: translateX(-50%) translateY(0); }
.toolbar-episode-info { pointer-events: auto; color: #ffffff; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; text-shadow: 0 1px 3px rgba(0,0,0,0.9); line-height: 1.3; max-width: 68%; }
.current-ep-number { font-size: 13px; font-weight: 700; color: #ffffff; letter-spacing: 0.5px; }
.current-ep-title { font-size: 14px; font-weight: 700; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.toolbar-actions { display: flex; align-items: flex-end; gap: 14px; }
.toolbar-btn {
    pointer-events: auto; display: flex; flex-direction: column; align-items: center;
    color: #ffffff; font-size: 11px; font-weight: bold; cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8); gap: 3px; user-select: none;
    min-width: 28px; text-decoration: none; transition: opacity 0.2s ease;
}
.toolbar-btn svg { width: 20px; height: 20px; fill: #ffffff; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8)); }
.toolbar-btn.disabled { opacity: 0.35 !important; cursor: not-allowed; pointer-events: none; }

/* ボトムシート（全話ポップアップ） */
.sheet-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); z-index: 200; opacity: 0; visibility: hidden; transition: opacity 0.3s ease;
}
.sheet-overlay.active { opacity: 1; visibility: visible; }
.bottom-sheet {
    position: fixed; bottom: 0; left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%; max-width: 520px; height: 75vh;
    background: #fff; border-radius: 16px 16px 0 0; z-index: 201;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex; flex-direction: column; font-family: sans-serif;
}
.bottom-sheet.active { transform: translateX(-50%) translateY(0); }
.sheet-header { display: flex; align-items: center; padding: 12px 15px; border-bottom: 1px solid #eee; }
.btn-close { background: none; border: none; cursor: pointer; padding: 5px; display: flex; align-items: center; justify-content: center; }
.btn-close svg { width: 20px; height: 20px; stroke: #333; stroke-width: 2.2; stroke-linecap: round; }
.sheet-title { font-size: 16px; font-weight: bold; color: #333; margin-left: 8px; }
.sheet-content { flex: 1; overflow-y: auto; padding: 10px 15px; overscroll-behavior-y: contain; }
.ep-item { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid #f0f0f0; text-decoration: none; color: inherit; }
.ep-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; background: #ddd; }
.ep-info { margin-left: 15px; flex: 1; }
.ep-title { font-size: 14px; font-weight: bold; color: #111; margin-bottom: 4px; }
.ep-date { font-size: 12px; color: #888; }

/* ▼▼ お気に入りに追加ボタン（左下） ▼▼ */
.btn-fav-add {
    pointer-events: auto; background-color: #ffffff; color: #0f172a; border: none; border-radius: 18px;
    padding: 6px 14px; font-size: 11.5px; font-weight: 700; margin-bottom: 8px; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4); display: inline-block; font-family: inherit; transition: opacity 0.2s;
}
.btn-fav-add:active { opacity: 0.85; }

/* ▼▼ お気に入り案内モーダル ▼▼ */
.fav-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.65); z-index: 300; opacity: 0; visibility: hidden; transition: opacity 0.3s ease;
}
.fav-modal-overlay.active { opacity: 1; visibility: visible; }
.fav-modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.92);
    width: 90%; max-width: 400px; background: #ffffff; border-radius: 16px; z-index: 301;
    opacity: 0; visibility: hidden; transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); font-family: sans-serif; overflow: hidden;
}
.fav-modal.active { transform: translate(-50%, -50%) scale(1); opacity: 1; visibility: visible; }
.fav-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; }
.fav-modal-title { font-size: 15px; font-weight: 800; color: #0f172a; }
.btn-fav-modal-close { background: none; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; }
.btn-fav-modal-close svg { width: 18px; height: 18px; stroke: #64748b; stroke-width: 2.2; stroke-linecap: round; }
.btn-fav-modal-close:hover svg { stroke: #0f172a; }
.fav-modal-content { padding: 16px 18px 20px; }
.guide-item { margin-bottom: 14px; }
.guide-item:last-child { margin-bottom: 0; }
.guide-label { font-size: 12.5px; font-weight: 700; color: #0284c7; margin-bottom: 4px; }
.guide-desc { font-size: 12.5px; color: #334155; line-height: 1.55; background-color: #f8fafc; padding: 10px 12px; border-radius: 8px; border: 1px solid #e2e8f0; }
.guide-desc strong { color: #0f172a; }
.inline-icon { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; margin: 0 2px; }
.inline-icon svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2.2; fill: none; vertical-align: middle; }

/* ▼▼ ボトムシート：総話数 ＆ 1話から/最新話から ▼▼ */
.sheet-subheader { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 8px; border-bottom: 1px solid #f1f5f9; }
.sheet-total-count { font-size: 14px; font-weight: 800; color: #0f172a; }
.sort-switch-pill { display: flex; background-color: #f1f5f9; border-radius: 20px; padding: 3px; gap: 2px; }
.sort-btn { border: none; background: transparent; padding: 5px 12px; font-size: 11.5px; font-weight: 700; color: #64748b; border-radius: 16px; cursor: pointer; transition: all 0.2s ease; line-height: 1.2; }
.sort-btn.active { background-color: #ffffff; color: #0284c7; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); border: 1px solid #38bdf8; }

/* ▼▼ 読んだ！ スタイル ▼▼ */
.ep-badge-read { font-size: 11px; font-weight: 700; color: #64748b; background-color: #f1f5f9; padding: 2px 7px; border-radius: 4px; margin-left: 10px; flex-shrink: 0; border: 1px solid #e2e8f0; }
.ep-item.is-read .ep-thumb { opacity: 0.6; filter: grayscale(20%); }
.ep-item.is-read .ep-title-line, .ep-item.is-read .ep-title { color: #64748b; }

/* ▼▼ 右上：ページ進捗インジケーター ▼▼ */
.page-indicator {
    position: fixed;
    top: 106px;
    right: max(16px, calc((100vw - 520px) / 2 + 16px));
    background: rgba(160, 160, 165, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 14px;
    letter-spacing: 0.5px;
    z-index: 95;
    pointer-events: none;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
body.toolbar-active .page-indicator { opacity: 1; transform: translateY(0); }
.page-indicator.hidden { opacity: 0 !important; transform: translateY(-10px) !important; }

/* ▼▼ 右上：縦型スクロールゲージ（操作可能なページ進捗バー） ▼▼ */
.page-scroll-gauge {
    position: fixed;
    top: 138px;
    right: max(12px, calc((100vw - 520px) / 2 + 12px));
    width: 28px;
    height: clamp(160px, 42vh, 340px);
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    padding: 0 4px;
    box-sizing: border-box;
    z-index: 96;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
body.toolbar-active .page-scroll-gauge { opacity: 1; pointer-events: auto; transform: translateY(0); }
.page-scroll-gauge.hidden { opacity: 0 !important; pointer-events: none !important; transform: translateY(-10px) !important; }

.page-scroll-gauge-track {
    position: relative;
    width: 8px;
    height: 100%;
    background: rgba(160, 160, 165, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 9999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.page-scroll-gauge-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 36px;
    background: #ffffff;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.05s linear;
}

.page-scroll-gauge.is-dragging .page-scroll-gauge-thumb {
    transition: none;
}

/* ▼▼ フッター左下の作品ロゴマーク ▼▼ */
.toolbar-logo-link {
    display: block;
    margin-bottom: 10px;
    pointer-events: auto;
    width: fit-content;
}

.toolbar-logo {
    display: block;
    width: 185px;      /* ロゴの横幅（お好みで 170px 210px で調整してください） */
    max-width: 100%;   /* 画面幅が狭い端末でもはみ出さないようにする安全策 */
    height: auto;
    /* 画像の黒背景を透過させ、フッターの黒グラデーションに自然に溶け込ませる設定 */
    mix-blend-mode: lighten;
}

/* ▼▼ 透過PNG専用：火の粉演出用のスタイル ▼▼ */
#fire-zone,
.fire-zone {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: transparent; /* 背景透過を保証 */
}

/* 透過PNG画像：黒背景を解除し、火の粉キャンバスより上の階層に置く */
#fire-zone img,
.fire-zone img {
    position: relative;
    background-color: transparent !important;
    z-index: 6; /* Canvas(z-index: 3) より前面に配置 */
}

/* 火の粉キャンバス：漫画枠内の黒背景(z-index: 0相当)とPNG(z-index: 6)の間に配置 */
#fire-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3; /* 画像の奥に配置される */
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* -------------------------------------------------------------
  スクロールバー設定（大きめ）
------------------------------------------------------------- */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: #121214; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.4); border-radius: 7px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.7); }
html { scrollbar-width: auto; scrollbar-color: rgba(255, 255, 255, 0.4) #121214; }

/* ▼▼ エピソード終了テキスト ＆ 次の話案内 ＆ 続きを読むボタン（漫画末尾・自動挿入） ▼▼ */
.ep-end-label {
    margin: 48px auto 32px;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.08em;
    white-space: pre;
    user-select: none;
}

.next-ep-preview {
    margin: 0 auto 28px;
    padding: 0 20px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    user-select: none;
}

.next-ep-number {
    font-size: 17px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.next-ep-title {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.35;
    letter-spacing: 0.02em;
}

.next-episode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 48px auto 80px;
    padding: 14px 36px;
    min-width: 240px;
    max-width: calc(100% - 32px);
    min-height: 52px;
    box-sizing: border-box;
    background-color: #E61E2B;
    color: #FFFFFF;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.04em;
    text-decoration: none;
    border-radius: 9999px;
    box-shadow: 0 4px 16px rgba(230, 30, 43, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.next-episode-btn svg {
    width: 20px;
    height: 20px;
    stroke: #FFFFFF;
    stroke-width: 2.6;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.next-episode-btn:hover {
    background-color: #f32b38;
    filter: brightness(1.06);
    box-shadow: 0 6px 20px rgba(230, 30, 43, 0.55), 0 3px 8px rgba(0, 0, 0, 0.45);
}

.next-episode-btn:active {
    transform: translateY(2px) scale(0.98);
    filter: brightness(0.96);
    box-shadow: 0 2px 8px rgba(230, 30, 43, 0.35), 0 1px 4px rgba(0, 0, 0, 0.4);
}

.ep-end-label + .next-episode-btn,
.next-ep-preview + .next-episode-btn {
    margin-top: 0;
}