/* ===================================
   基本設定とリセット
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "ヒラギノ角ゴ ProN W3", Meiryo, sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===================================
   マンガビューアコンテナ
   =================================== */
.manga-viewer {
    position: relative;
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: #000;
    overflow: hidden;
}

/* ===================================
   ページコンテナ
   =================================== */
.page-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* ===================================
   マンガページ画像
   =================================== */
.manga-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transform: translateX(100%);
    transition: none;
    pointer-events: none;
    background-color: #000;
    display: none;
}

.manga-page.active {
    display: block !important;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    z-index: 2;
}

/* スライドアニメーション（次へ - 右開き）*/
.manga-page.slide-out-next {
    display: block;
    animation: slideOutRight 0.4s ease-in-out forwards;
    z-index: 1;
}

.manga-page.slide-in-next {
    display: block;
    animation: slideInLeft 0.4s ease-in-out forwards;
    z-index: 2;
}

/* スライドアニメーション（前へ - 右開き） */
.manga-page.slide-out-prev {
    display: block;
    animation: slideOutLeft 0.4s ease-in-out forwards;
    z-index: 1;
}

.manga-page.slide-in-prev {
    display: block;
    animation: slideInRight 0.4s ease-in-out forwards;
    z-index: 2;
}

/* アニメーション定義 */
/* 左へスライドアウト */
@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* 左からスライドイン */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 右へスライドアウト */
@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* 右からスライドイン */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===================================
   タップエリア
   =================================== */
.tap-area {
    position: absolute;
    top: 0;
    width: 33.33%;
    height: 100%;
    z-index: 50;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tap-left {
    left: 0;
}

.tap-center {
    left: 33.33%;
}

.tap-right {
    right: 0;
}

.tap-area:active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ===================================
   ページインジケーター
   =================================== */
.page-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 100;
    backdrop-filter: blur(10px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page-indicator.visible {
    opacity: 1;
}

/* ===================================
   ナビゲーションガイド
   =================================== */
.navigation-guide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.navigation-guide.fade-out {
    opacity: 0;
}

.guide-content {
    display: flex;
    width: 100%;
    height: 100%;
}

.guide-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    text-align: center;
}

.guide-icon {
    font-size: 48px;
    margin-bottom: 10px;
    animation: bounce 1s infinite;
}

.guide-left .guide-icon {
    animation: bounceLeft 1s infinite;
}

.guide-center .guide-icon {
    animation: bounceUp 1s infinite;
}

.guide-right .guide-icon {
    animation: bounceRight 1s infinite;
}

.guide-zone p {
    font-size: 16px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes bounceLeft {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-10px);
    }
}

@keyframes bounceRight {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(10px);
    }
}

@keyframes bounceUp {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ===================================
   設定ボタン
   =================================== */
.settings-button {
    position: absolute;
    top: 70px;
    left: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    opacity: 0;
}

.settings-button.visible {
    opacity: 1;
}

.settings-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.settings-button:active {
    transform: scale(0.95);
}

/* ===================================
   最初から読むボタン
   =================================== */
.restart-button {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.restart-button.visible {
    opacity: 1;
    pointer-events: auto;
}

.restart-button:hover {
    background-color: rgba(102, 126, 234, 0.9);
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.restart-button:active {
    transform: translateY(0);
}

.restart-icon {
    font-size: 18px;
    animation: rotateIcon 2s linear infinite;
}

@keyframes rotateIcon {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.restart-button:hover .restart-icon {
    animation: rotateIcon 0.6s linear infinite;
}

/* ===================================
   設定パネル
   =================================== */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.settings-panel.active {
    display: flex;
}

.settings-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.settings-content h3 {
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
    color: #ffffff;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #ffffff;
}

.toggle-group {
    display: flex;
    gap: 10px;
}

.toggle-btn {
    flex: 1;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.toggle-btn.active {
    background-color: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border-color: #ffffff;
}

.close-settings {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    color: #ffffff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-settings:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

.close-settings:active {
    transform: scale(0.98);
}

/* ===================================
   最終ページCTA（Call To Action）
   =================================== */
.cta-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.cta-overlay.active {
    display: flex;
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.cta-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.6s ease forwards;
    position: relative;
}

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

.cta-header {
    text-align: center;
    margin-bottom: 30px;
}

.cta-title {
    font-size: 26px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 10px;
    line-height: 1.4;
}

.cta-subtitle {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    margin-top: 10px;
}

.cta-body {
    text-align: center;
}

.cta-message {
    font-size: 16px;
    color: #ffffff;
    line-height: 1.8;
    margin-bottom: 30px;
    opacity: 0.95;
}

.cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.cta-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.cta-button.primary {
    background-color: #ffd700;
    color: #333;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.cta-button.primary:hover {
    background-color: #ffed4e;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
}

.cta-button.secondary {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.cta-button.secondary:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: #ffffff;
    transform: translateY(-3px);
}

.button-icon {
    font-size: 22px;
}

.cta-share {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.share-text {
    font-size: 14px;
    color: #ffffff;
    margin-bottom: 15px;
    opacity: 0.9;
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.share-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.share-btn.twitter:hover {
    background-color: #1da1f2;
    border-color: #1da1f2;
}

.share-btn.line:hover {
    background-color: #00b900;
    border-color: #00b900;
}

.share-btn.copy:hover {
    background-color: #6c757d;
    border-color: #6c757d;
}

.share-icon {
    font-size: 16px;
}

.cta-close {
    width: 100%;
    padding: 12px;
    margin-top: 25px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cta-close:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

.cta-close:active {
    transform: scale(0.98);
}

.cta-close span {
    margin-right: 5px;
}

/* ===================================
   レスポンシブ対応
   =================================== */
@media screen and (max-width: 768px) {
    .page-indicator {
        font-size: 12px;
        padding: 6px 12px;
        top: 15px;
        left: 15px;
    }
    
    .settings-button {
        top: 55px;
        left: 15px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .restart-button {
        top: 15px;
        right: 15px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .restart-icon {
        font-size: 16px;
    }
    
    .restart-text {
        display: none;
    }

    .guide-icon {
        font-size: 36px;
    }

    .guide-zone p {
        font-size: 14px;
    }
    
    .settings-content {
        padding: 20px;
    }
    
    .settings-content h3 {
        font-size: 20px;
    }
    
    .toggle-btn {
        font-size: 12px;
        padding: 10px;
    }
    
    .cta-content {
        padding: 30px 20px;
        width: 95%;
    }
    
    .cta-title {
        font-size: 22px;
    }
    
    .cta-subtitle {
        font-size: 18px;
    }
    
    .cta-message {
        font-size: 15px;
    }
    
    .cta-button {
        font-size: 16px;
        padding: 14px 20px;
    }
    
    .share-buttons {
        gap: 8px;
    }
    
    .share-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* ===================================
   ローディング状態
   =================================== */
.manga-page[data-src]:not([src]) {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23000"/><text x="50" y="50" font-size="14" fill="%23666" text-anchor="middle" dominant-baseline="middle">Loading...</text></svg>');
    background-repeat: no-repeat;
    background-position: center;
}
