@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;700&family=Noto+Sans+CJK+JP:wght@400;500;700&family=Noto+Serif+JP:wght@400;600&display=swap');

:root {
    /* メインパレット（モダン・クラシック） */
    --bg-color:        #F4F5F7; /* 落ち着いたライトグレー */
    --container-bg:    #FFFFFF; /* 純白カード背景 */
    --primary-text:    #1E293B; /* 深みのあるスレートダーク（最高レベルの可読性） */
    --accent-main:     #2563EB; /* 鮮やかで品のあるサファイアブルー */
    --accent-hover:    #1D4ED8; /* ディープブルー */
    --border-color:    #E2E8F0; /* 繊細な境界線 */
    --muted-text:      #64748B; /* スレートグレー */
    
    /* 読書画面用（ダークモードシアター × 温かみのある高級ペーパー） */
    --reader-bg:       #0F172A; /* 深遠なミッドナイトブルー */
    --paper-bg:        #FDFBF7; /* 目の疲労を和らげる最高級生成り紙色 */
    --paper-text:      #1A1A1A; /* 墨色テキスト */
    --paper-border:    #E5E0D8; /* 羊皮紙のような境界線 */
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    font-family: 'Noto Sans CJK JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-text);
    -webkit-font-smoothing: antialiased;
}

/* 共通コンテナ（一覧画面用） */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 見出し */
h2 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-text);
    font-weight: 700;
    font-size: 1.6rem;
    text-align: center;
    letter-spacing: 0.25em;
    margin: 0 0 40px 0;
    padding-bottom: 14px;
    position: relative;
    display: inline-block;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 3px;
    background-color: var(--accent-main);
    border-radius: 3px;
}

/* カードグリッド */
.grid-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 32px;
    width: 100%;
}

.thumb-card {
    display: flex;
    flex-direction: column;
    width: 230px;
    height: auto;
    flex-shrink: 0;
    background-color: var(--container-bg);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.thumb-card:hover {
    transform: translateY(-8px);
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 20px 30px -10px rgba(37, 99, 235, 0.15);
}

.thumb-screen {
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    background-color: #F1F5F9;
    overflow: hidden;
}

.thumb-screen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.thumb-card:hover .thumb-screen img {
    transform: scale(1.06);
}

.thumb-info {
    padding: 16px;
    background-color: var(--container-bg);
    border-top: 1px solid var(--border-color);
}

.thumb-title {
    font-family: 'Noto Sans CJK JP', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--primary-text);
    margin: 0;
    text-align: center;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
    transition: color 0.2s ease;
}

.thumb-card:hover .thumb-title {
    color: var(--accent-main);
}

/* ==========================================================================
   小説ビューア画面（夜の書斎風シアターモード）
   ========================================================================== */

.novel-body {
    background-color: var(--reader-bg);
    color: #F1F5F9;
    overflow-x: hidden;
}

.novel-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    box-sizing: border-box;
}

.novel-header {
    width: 100%;
    max-width: 620px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.back-btn {
    color: #94A3B8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.novel-header-title {
    font-size: 0.98rem;
    font-weight: 500;
    margin: 0;
    color: #CBD5E1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3:4固定ステージ */
.stage-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

/* 縦書きビューア（3:4固定枠・スクロールバー完全非表示） */
.novel-viewer {
    aspect-ratio: 3 / 4;
    height: 100%;
    max-height: 80vh;
    max-width: calc(80vh * 0.75);
    background-color: var(--paper-bg);
    color: var(--paper-text);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--paper-border);
    box-sizing: border-box;
    padding: 38px 30px;
    
    /* 縦書き設定 */
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    
    /* 横スクロール（右から左へ文章を流す） */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* スマホでの滑らかな慣性スクロール */

    /* --- スクロールバー非表示（Firefox / IE / Edge） --- */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* --- スクロールバー非表示（Chrome / Safari） --- */
.novel-viewer::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* 本文エリア（修正後） */
.novel-content {
    font-family: 'Noto Serif JP', 'Yu Mincho', '游明朝', serif;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.8;
    letter-spacing: 0.05em;
    height: 100%;
    width: max-content;
}

/* 段落・見出しの縦書き調整 */
.novel-content p {
    margin: 0 0 0 1.5em; /* 縦書き時の段落間隔（左側にマージン） */
    text-align: justify;
}

.novel-content h1, 
.novel-content h2, 
.novel-content h3 {
    font-weight: 600;
    margin: 0 0 0 2em;
    color: #0F172A;
}

.novel-footer {
    height: 24px; /* 余白調整のみ */
}

/* レスポンシブ調整 */
@media (max-width: 600px) {
    .thumb-card {
        width: 150px;
        border-radius: 12px;
    }
    .thumb-info {
        padding: 10px;
    }
    .thumb-title {
        font-size: 0.85rem;
    }
    .novel-viewer {
        padding: 24px 18px;
    }
    .novel-content {
        font-size: 20px;
        line-height: 1.85;
    }
}