/* ============================================
   My Life is My Message — メインスタイルシート
   明治浪漫×水彩画テーマ
   ============================================ */

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

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

:root {
    --color-bg: #1a1410;
    --color-text: #f0e6d3;
    --color-accent: #c4956a;
    --color-accent-light: #e8cba8;
    --color-window-bg: rgba(20, 15, 10, 0.88);
    --color-window-border: rgba(196, 149, 106, 0.5);
    --color-choice-bg: rgba(30, 22, 15, 0.92);
    --color-choice-hover: rgba(196, 149, 106, 0.3);
    --font-main: 'Shippori Mincho', 'Noto Serif JP', serif;
    --text-speed: 40ms;
    /* カード用カラー */
    --card-navy: #0a1128;
    --card-gold: #d4a843;
    --card-gold-light: #e8cfa0;
    --suit-spade: #4a6fa5;
    --suit-heart: #c0392b;
    --suit-diamond: #e67e22;
    --suit-club: #27ae60;
    --suit-joker: #d4a843;
    /* セーブ/ロードモード色 */
    --saveload-save-color: #c4956a;
    --saveload-load-color: #5dade2;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--color-bg);
    font-family: var(--font-main);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* --- 画面管理 --- */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    z-index: 1;
}
.screen.active {
    display: flex;
}
.overlay-screen {
    z-index: 100;
    background: rgba(10, 8, 5, 0.95);
    flex-direction: column;
    padding: 2rem;
}

/* ============================================
   タイトル画面
   ============================================ */
#title-screen {
    background: linear-gradient(
        135deg,
        #1a1410 0%,
        #2a1f15 30%,
        #1a1410 60%,
        #2a1f15 100%
    );
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.title-overlay {
    text-align: center;
    animation: titleFadeIn 2s ease-out;
}

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

.title-main {
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--color-accent-light);
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 20px rgba(196, 149, 106, 0.3);
}

.title-sub {
    font-size: 1.1rem;
    color: var(--color-accent);
    letter-spacing: 0.3em;
    margin-bottom: 3rem;
    opacity: 0.8;
}

.title-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.title-btn {
    display: block;
    width: 280px;
    padding: 0.9rem 2rem;
    background: transparent;
    border: 1px solid var(--color-window-border);
    color: var(--color-text);
    font-family: var(--font-main);
    font-size: 1.05rem;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 48px;
}

.title-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(196,149,106,0.15), transparent);
    transition: left 0.5s ease;
}

.title-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent-light);
    text-shadow: 0 0 8px rgba(196, 149, 106, 0.3);
}
.title-btn:hover::before {
    left: 100%;
}

/* つづきからボタン無効時 */
.title-btn:disabled,
.title-btn[disabled] {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}
.title-btn:disabled::before {
    display: none;
}

/* タイトルボタンのサブテキスト */
.title-btn-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--color-accent);
    opacity: 0.6;
    margin-top: 0.2rem;
    letter-spacing: 0.1em;
}

/* ============================================
   ゲーム画面
   ============================================ */
#game-screen {
    position: relative;
    overflow: hidden;
}

/* --- 背景 --- */
.bg-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    transition: opacity 1s ease;
    z-index: 1;
}

/* --- キャラクター立ち絵 --- */
.chara-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    pointer-events: none;
}

.chara-img {
    position: absolute;
    bottom: 200px;
    max-height: 60%;
    max-width: 45%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.chara-img.visible {
    opacity: 1;
}
.chara-left {
    left: 5%;
    transform: translateX(-10px);
}
.chara-left.visible {
    transform: translateX(0);
}
.chara-center {
    left: 50%;
    transform: translateX(-50%);
}
.chara-right {
    right: 5%;
    transform: translateX(10px);
}
.chara-right.visible {
    transform: translateX(0);
}

/* --- イベントCG --- */
.event-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 20;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.event-layer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- テキストウィンドウ --- */
.text-window {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    min-height: 200px;
    background: var(--color-window-bg);
    border-top: 1px solid var(--color-window-border);
    z-index: 50;
    padding: 1rem 2.5rem 1.5rem 2.5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.speaker-name {
    font-size: 0.95rem;
    color: var(--color-accent);
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    min-height: 1.3em;
    font-weight: 700;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.text-body {
    font-size: 1.05rem;
    line-height: 1.9;
    letter-spacing: 0.06em;
    color: var(--color-text);
    min-height: 4em;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.text-cursor {
    position: absolute;
    bottom: 0.8rem;
    right: 2.5rem;
    color: var(--color-accent);
    animation: cursorBlink 1s ease-in-out infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* --- 選択肢 --- */
.choices-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 60;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.choice-btn {
    width: 60%;
    max-width: 500px;
    padding: 1rem 2rem;
    background: var(--color-choice-bg);
    border: 1px solid var(--color-window-border);
    color: var(--color-text);
    font-family: var(--font-main);
    font-size: 1.05rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 48px;
}

.choice-btn:hover {
    background: var(--color-choice-hover);
    border-color: var(--color-accent);
    color: var(--color-accent-light);
    transform: scale(1.02);
}

/* --- 章タイトルオーバーレイ --- */
.chapter-title-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 70;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 1s ease;
}
.chapter-title-overlay.visible {
    opacity: 1;
}

.chapter-title-number {
    font-size: 1rem;
    color: var(--color-accent);
    letter-spacing: 0.5em;
    margin-bottom: 1rem;
}

.chapter-title-name {
    font-size: 2.5rem;
    color: var(--color-accent-light);
    letter-spacing: 0.2em;
    margin-bottom: 0.8rem;
    text-shadow: 0 2px 15px rgba(196, 149, 106, 0.3);
}

.chapter-title-keyword {
    font-size: 0.9rem;
    color: var(--color-accent);
    letter-spacing: 0.3em;
    opacity: 0.85;
    font-style: italic;
}


/* ============================================
   ゲーム内UI — 2層構造メニュー（商業品質）
   ============================================ */

/* --- 旧メニューバー：非表示 --- */
.game-menu-bar {
    display: none !important;
}

/* --- 層1：テキストボックス内インラインコントロール --- */
#textbox-controls {
    position: absolute;
    bottom: 10px;
    right: 16px;
    display: flex;
    gap: 4px;
    align-items: center;
    z-index: 55;
}

#textbox-controls button {
    background: none;
    border: 1px solid transparent;
    color: rgba(196, 149, 106, 0.65);
    font-size: 0.7rem;

    font-family: var(--font-main);
    letter-spacing: 0.12em;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 3px;
    transition: color 0.25s, background 0.25s, border-color 0.25s;
    min-height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

#textbox-controls button:hover {
    color: rgba(232, 203, 168, 0.85);
    background: rgba(196, 149, 106, 0.08);
    border-color: rgba(196, 149, 106, 0.15);
}

#textbox-controls button.active {
    color: var(--color-accent-light);
    background: rgba(196, 149, 106, 0.12);
    border-color: rgba(196, 149, 106, 0.3);
}

/* メニューボタン専用スタイル — MENU表記化により他ボタンと統一 */

/* --- カードバッジ（右上・常時表示） --- */
#card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(10, 8, 5, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 168, 67, 0.25);
    border-radius: 20px;
    padding: 5px 14px;
    color: rgba(212, 168, 67, 0.8);
    font-size: 0.75rem;

    font-family: var(--font-main);
    letter-spacing: 0.1em;
    z-index: 80;
    cursor: pointer;
    transition: background 0.25s, color 0.25s, border-color 0.25s;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
}

#card-badge:hover {
    background: rgba(10, 8, 5, 0.65);
    color: rgba(212, 168, 67, 0.85);
    border-color: rgba(212, 168, 67, 0.4);
}

#card-badge .badge-icon {
    font-size: 0.85rem;
    line-height: 1;
}

/* --- 層2：スライドメニューパネル --- */
#menu-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10, 8, 5, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
}
#menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

#menu-panel {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: linear-gradient(
        180deg,
        rgba(25, 18, 12, 0.97) 0%,
        rgba(35, 25, 16, 0.97) 100%
    );
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    padding: 0;
    border-left: 1px solid rgba(196, 149, 106, 0.12);
    display: flex;
    flex-direction: column;
}
#menu-panel.open {
    right: 0;
}

/* パネルヘッダー */
.menu-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(196, 149, 106, 0.08);
}

.menu-panel-title {
    font-size: 0.75rem;
    color: rgba(196, 149, 106, 0.5);
    letter-spacing: 0.3em;
}

.menu-panel-close {
    width: 36px; height: 36px;
    background: none;
    border: 1px solid rgba(196, 149, 106, 0.2);
    border-radius: 4px;
    color: rgba(196, 149, 106, 0.5);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-height: 36px;
    min-width: 36px;
}
.menu-panel-close:hover {
    border-color: rgba(196, 149, 106, 0.5);
    color: var(--color-accent-light);
    background: rgba(196, 149, 106, 0.08);
}

/* パネルメニュー項目 */
.menu-panel-body {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.menu-panel-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid rgba(196, 149, 106, 0.05);
    color: rgba(240, 230, 211, 0.85);
    font-size: 0.95rem;

    font-family: var(--font-main);
    padding: 16px 24px;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, padding-left 0.25s;
    letter-spacing: 0.12em;
}
.menu-panel-item:hover {
    color: var(--color-accent-light);
    background: rgba(196, 149, 106, 0.06);
    padding-left: 30px;
}

.menu-panel-item .item-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
    opacity: 0.6;
    flex-shrink: 0;
}
.menu-panel-item:hover .item-icon {
    opacity: 1;
}

.menu-panel-item .item-badge {
    margin-left: auto;
    background: rgba(212, 168, 67, 0.12);
    color: var(--card-gold);
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 10px;
    letter-spacing: 0.05em;
}

/* パネルフッター */
.menu-panel-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(196, 149, 106, 0.08);
    text-align: center;
}
.menu-panel-footer .footer-text {
    font-size: 0.65rem;
    color: rgba(196, 149, 106, 0.25);
    letter-spacing: 0.15em;
}

/* ============================================
   バックログ
   ============================================ */
.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-window-border);
}
.overlay-header h2 {
    font-size: 1.3rem;
    color: var(--color-accent-light);
    letter-spacing: 0.2em;
}

.close-btn {
    width: 2.8rem; height: 2.8rem;
    background: transparent;
    border: 1px solid var(--color-window-border);
    color: var(--color-accent);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    border-radius: 4px;
}
.close-btn:hover {
    background: rgba(196, 149, 106, 0.2);
    border-color: var(--color-accent);
}

.overlay-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 1rem;
}

.backlog-entry {
    margin-bottom: 1rem;
    padding: 0.8rem;
    border-bottom: 1px solid rgba(196, 149, 106, 0.15);
}
.backlog-speaker {
    color: var(--color-accent);
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    letter-spacing: 0.1em;
}
.backlog-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--color-text);
    opacity: 0.92;
}


/* ============================================
   セーブ/ロード画面（改修版）
   ============================================ */
.saveload-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: auto;
    align-items: start;
    gap: 1rem;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

/* セーブモード時のタイトル色 */
#saveload-title.saveload-mode-save {
    color: var(--saveload-save-color);
}
#saveload-title.saveload-mode-load {
    color: var(--saveload-load-color);
}

.save-slot {
    padding: 1.2rem;
    background: rgba(30, 22, 15, 0.6);
    border: 1px solid var(--color-window-border);
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 80px;
    border-radius: 4px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}
.save-slot:hover {
    background: rgba(196, 149, 106, 0.15);
    border-color: var(--color-accent);
}
.save-slot-number {
    font-size: 0.8rem;
    color: var(--color-accent);
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
}
.save-slot-info {
    font-size: 0.9rem;
    line-height: 1.5;
}
.save-slot-date {
    font-size: 0.75rem;
    color: var(--color-accent);
    opacity: 0.6;
    margin-top: 0.3rem;
}

/* 空スロット改修 */
.save-slot.empty {
    opacity: 0.6;
    border-style: dashed;
}
.save-slot.empty:hover {
    opacity: 0.85;
}
.save-slot-empty-label {
    font-size: 0.85rem;
    color: var(--color-accent);
    opacity: 0.7;
    letter-spacing: 0.1em;
}


/* スロット削除ボタン */
.save-slot-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    background: rgba(180, 60, 60, 0.15);
    border: 1px solid rgba(180, 60, 60, 0.4);
    border-radius: 4px;
    color: rgba(180, 60, 60, 0.7);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-height: 28px;
    min-width: 28px;
}
.save-slot-delete:hover {
    background: rgba(180, 60, 60, 0.3);
    border-color: rgba(180, 60, 60, 0.7);
    color: #e74c3c;
}

/* ============================================
   設定画面
   ============================================ */
.settings-content {
    max-width: 500px;
    margin: 0 auto;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.setting-item label {
    flex: 0 0 120px;
    font-size: 0.95rem;
    color: var(--color-accent-light);
    letter-spacing: 0.1em;
}
.setting-item input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(196, 149, 106, 0.3);
    border-radius: 2px;
    outline: none;
}
.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px; height: 20px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
}
.setting-item span {
    flex: 0 0 30px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--color-accent);
}

/* ============================================
   ガルストカード（コレクション）
   ============================================ */

/* --- スートタブ --- */
.collection-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.collection-tab {
    padding: 0.5rem 1.2rem;
    background: transparent;
    border: 1px solid var(--color-window-border);
    color: var(--color-text);
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.15em;
    min-height: 44px;
    display: flex;
    align-items: center;
    border-radius: 4px;
}
.collection-tab.active,
.collection-tab:hover {
    background: rgba(196, 149, 106, 0.2);
    border-color: var(--color-accent);
    color: var(--color-accent-light);
}

/* スート記号の色分け */
.suit-icon-spade { color: var(--suit-spade); }
.suit-icon-heart { color: var(--suit-heart); }
.suit-icon-diamond { color: var(--suit-diamond); }
.suit-icon-club { color: var(--suit-club); }
.suit-icon-joker { color: var(--suit-joker); }

/* --- 収集進捗バー --- */
.collection-progress {
    margin-bottom: 1rem;
    padding: 0.3rem 0;
}
.collection-progress-text {
    font-size: 0.8rem;
    color: var(--color-accent);
    letter-spacing: 0.1em;
    margin-bottom: 0.3rem;
}
.collection-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(196, 149, 106, 0.15);
    border-radius: 2px;
    overflow: hidden;
}
.collection-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--card-gold), var(--card-gold-light));
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* --- カードグリッド --- */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.7rem;
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
    align-content: start;
}

/* --- カード1枚の外枠 --- */
.garst-card {
    aspect-ratio: 5/7;
    perspective: 800px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.garst-card:hover {
    transform: translateY(-4px);
}
.garst-card.locked {
    cursor: default;
}
.garst-card.locked:hover {
    transform: none;
}

/* --- カード内側（めくりアニメーション用） --- */
.garst-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

/* めくりアニメーション */
.garst-card.unlocking .garst-card-inner {
    animation: cardFlip 0.8s ease forwards;
}
@keyframes cardFlip {
    0%   { transform: rotateY(0deg); }
    50%  { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

/* --- カード裏面（未入手） --- */
.garst-card-back {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    overflow: hidden;
    background: var(--card-navy);
    border: 2px solid rgba(212, 168, 67, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}
.garst-card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}
.garst-card-back-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        var(--card-navy) 0%,
        #112244 50%,
        var(--card-navy) 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    border-radius: 4px;
    border: 1px solid rgba(212, 168, 67, 0.2);
}
.garst-card-back-fallback::before {
    content: '🃏';
    font-size: 1.8rem;
    opacity: 0.4;
}
.garst-card-back-fallback::after {
    content: 'GARST';
    font-size: 0.55rem;
    color: var(--card-gold);
    opacity: 0.3;
    letter-spacing: 0.3em;
}

/* --- カード表面（入手済み） --- */
.garst-card-front {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 2px solid rgba(212, 168, 67, 0.4);
    background: linear-gradient(
        180deg,
        #f5f0e8 0%,
        #ede5d8 100%
    );
    color: #2a1f15;
}

.garst-card-front.has-image {
    background: none;
}
.garst-card-front.has-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.3rem 0.4rem 0;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
}
.card-rank-suit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
}
.card-rank {
    font-size: 0.75rem;
    font-weight: 700;
}
.card-suit-small {
    font-size: 0.7rem;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.2rem;
    text-align: center;
    gap: 0.15rem;
}
.card-icon {
    font-size: 1.6rem;
    line-height: 1;
}
.card-suit-large {
    font-size: 1.2rem;
    opacity: 0.15;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    pointer-events: none;
}
.card-title {
    font-size: 0.5rem;
    font-weight: 700;
    line-height: 1.3;
    color: #2a1f15;
    padding: 0 0.2rem;
    max-height: 2.6em;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 0.4rem 0.3rem;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
}
.card-rank-suit-inv {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    transform: rotate(180deg);
}

/* --- スート別の枠色 --- */
.garst-card-front.suit-spade { border-color: var(--suit-spade); }
.garst-card-front.suit-heart { border-color: var(--suit-heart); }
.garst-card-front.suit-diamond { border-color: var(--suit-diamond); }
.garst-card-front.suit-club { border-color: var(--suit-club); }
.garst-card-front.suit-joker {
    border-color: var(--suit-joker);
    background: linear-gradient(135deg, #1a1410 0%, #2a1f15 50%, #1a1410 100%);
    color: var(--card-gold);
}
.garst-card-front.suit-joker .card-title { color: var(--card-gold); }
.garst-card-front.suit-joker .card-rank { color: var(--card-gold); }

/* --- ロック状態の表示切替 --- */
.garst-card.locked .garst-card-front { display: none; }
.garst-card.locked .garst-card-back { display: flex; }
.garst-card.unlocked .garst-card-front { display: flex; }
.garst-card.unlocked .garst-card-back { display: none; }

/* --- カード入手時の光彩エフェクト --- */
.garst-card.newly-unlocked {
    animation: cardGlow 1.5s ease-out;
}
@keyframes cardGlow {
    0%   { box-shadow: 0 0 0 rgba(212, 168, 67, 0); }
    30%  { box-shadow: 0 0 20px rgba(212, 168, 67, 0.8); }
    100% { box-shadow: 0 0 0 rgba(212, 168, 67, 0); }
}

/* --- カード入手ポップアップ --- */
.card-unlock-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 200;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    animation: popupFadeIn 0.5s ease;
}
@keyframes popupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.card-unlock-popup-title {
    font-size: 0.9rem;
    color: var(--card-gold);
    letter-spacing: 0.3em;
    animation: popupSlideDown 0.5s ease 0.2s both;
}
@keyframes popupSlideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-unlock-popup-card {
    width: 160px;
    aspect-ratio: 5/7;
    animation: popupCardReveal 0.8s ease 0.4s both;
}
@keyframes popupCardReveal {
    0%   { opacity: 0; transform: scale(0.5) rotateY(180deg); }
    60%  { opacity: 1; transform: scale(1.05) rotateY(0deg); }
    100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

.card-unlock-popup-name {
    font-size: 1.1rem;
    color: var(--color-accent-light);
    letter-spacing: 0.15em;
    animation: popupSlideDown 0.5s ease 0.8s both;
}

.card-unlock-popup-hint {
    font-size: 0.75rem;
    color: var(--color-accent);
    opacity: 0.6;
    animation: popupSlideDown 0.5s ease 1s both;
}

/* --- カード詳細オーバーレイ --- */
.collection-detail-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 150;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.collection-detail-panel {
    position: relative;
    background: rgba(15, 12, 8, 0.97);
    border: 1px solid var(--color-window-border);
    border-radius: 8px;
    width: 100%;
    max-width: 680px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
}

.collection-detail-panel .close-btn {
    position: absolute;
    top: 0.8rem; right: 0.8rem;
    z-index: 10;
}

.card-detail-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.card-detail-card {
    flex: 0 0 150px;
    aspect-ratio: 5/7;
}
.card-detail-card .garst-card-front {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.card-detail-info {
    flex: 1;
    min-width: 0;
}
.card-detail-suit-rank {
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}
.card-detail-title {
    font-size: 1.2rem;
    color: var(--color-accent-light);
    letter-spacing: 0.15em;
    margin-bottom: 0.8rem;
}
.card-detail-content {
    font-size: 0.95rem;
    line-height: 1.9;
    margin-bottom: 0.8rem;
    color: var(--color-text);
}
.card-detail-meta {
    font-size: 0.85rem;
    color: var(--color-accent);
    opacity: 0.7;
    border-top: 1px solid var(--color-window-border);
    padding-top: 0.8rem;
}
.card-detail-chapter {
    font-size: 0.75rem;
    color: var(--color-accent);
    opacity: 0.5;
    margin-top: 0.4rem;
}

/* カード詳細画面のカード部分：zoom-inカーソルヒント */
.card-detail-card[style*="cursor: zoom-in"]::after {
    content: '🔍 タップで拡大';
    position: absolute;
    bottom: -1.4rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--color-accent);
    opacity: 0.4;
    white-space: nowrap;
    letter-spacing: 0.05em;
    pointer-events: none;
}

@media (max-width: 768px) {
    .collection-detail-overlay {
        padding: 1rem;
    }
    .collection-detail-panel {
        padding: 1.5rem;
        max-height: 85vh;
    }
    .card-detail-layout {
        flex-direction: column;
        align-items: center;
    }
    .card-detail-card {
        flex: 0 0 auto;
        width: 120px;
    }
}

/* ============================================
   カード拡大ビューア（フルスクリーン風）
   ============================================ */
.card-fullview-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 500;
    background: rgba(5, 4, 2, 0.97);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: cardFullviewIn 0.4s ease;
    cursor: zoom-out;
    padding: 1rem;
}

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

.card-fullview-overlay.closing {
    animation: cardFullviewOut 0.3s ease forwards;
}

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

/* カード本体ラッパー */
.card-fullview-card {
    width: 80vmin;
    max-width: 400px;
    aspect-ratio: 5 / 7;
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
        0 0 60px rgba(212, 168, 67, 0.15),
        0 4px 30px rgba(0, 0, 0, 0.6);
    animation: cardFullviewZoom 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    flex-shrink: 0;
}

@keyframes cardFullviewZoom {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

/* 画像カードの場合 */
.card-fullview-card img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* テキストカード（画像なし）の場合 */
.card-fullview-card .garst-card-front {
    position: relative;
    width: 100%; height: 100%;
    border-radius: 12px;
    font-size: 1rem;
}

.card-fullview-card .garst-card-front .card-header {
    padding: 0.8rem 1rem 0;
}

.card-fullview-card .garst-card-front .card-rank {
    font-size: 1.8rem;
}

.card-fullview-card .garst-card-front .card-suit-small {
    font-size: 1.6rem;
}

.card-fullview-card .garst-card-front .card-icon {
    font-size: 4rem;
}

.card-fullview-card .garst-card-front .card-suit-large {
    font-size: 3rem;
}

.card-fullview-card .garst-card-front .card-title {
    font-size: 1.1rem;
    max-height: none;
    padding: 0 0.8rem;
}

.card-fullview-card .garst-card-front .card-footer {
    padding: 0 1rem 0.8rem;
}

.card-fullview-card .garst-card-front .card-body {
    gap: 0.5rem;
}

/* カード下の情報テキスト */
.card-fullview-info {
    margin-top: 1.2rem;
    text-align: center;
    max-width: 400px;
    animation: cardFullviewInfoIn 0.5s ease 0.3s both;
}

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

.card-fullview-title {
    font-size: 1.1rem;
    color: var(--color-accent-light);
    letter-spacing: 0.12em;
    margin-bottom: 0.4rem;
}

.card-fullview-suit-rank {
    font-size: 0.8rem;
    color: var(--color-accent);
    opacity: 0.6;
    letter-spacing: 0.15em;
    margin-bottom: 0.3rem;
}

.card-fullview-meta {
    font-size: 0.75rem;
    color: var(--color-accent);
    opacity: 0.4;
    letter-spacing: 0.1em;
}

/* 閉じるヒント */
.card-fullview-hint {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(168, 140, 90, 0.3);
    letter-spacing: 0.15em;
    pointer-events: none;
    animation: cardFullviewInfoIn 0.5s ease 0.6s both;
}

/* 閉じるボタン（右上） */
.card-fullview-close {
    position: absolute;
    top: 1rem; right: 1rem;
    width: 44px; height: 44px;
    background: rgba(20, 15, 10, 0.6);
    border: 1px solid rgba(168, 140, 90, 0.3);
    border-radius: 50%;
    color: rgba(168, 140, 90, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    min-height: 44px;
    min-width: 44px;
}

.card-fullview-close:hover {
    background: rgba(20, 15, 10, 0.8);
    border-color: rgba(168, 140, 90, 0.6);
    color: var(--color-accent-light);
}

/* ============================================
   ユーティリティ
   ============================================ */
.hidden {
    display: none !important;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(20, 15, 10, 0.5); }
::-webkit-scrollbar-thumb { background: var(--color-accent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-accent-light); }

/* フェードアニメーション用 */
.fade-in { animation: fadeIn 0.5s ease-out forwards; }
.fade-out { animation: fadeOut 0.5s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ============================================
   レスポンシブ対応（改修版）
   ============================================ */
@media (max-width: 768px) {
    .title-main { font-size: 2rem; }
    .title-sub { font-size: 0.9rem; }
    .title-btn { width: 260px; }
    .text-window {
        padding: 0.8rem 1.5rem 1rem 1.5rem;
        min-height: 160px;
    }
    .chara-img {
        bottom: 160px;
        max-height: 50%;
        max-width: 50%;
    }
    .text-body { font-size: 0.95rem; }
    .choice-btn {
        width: 85%;
        font-size: 0.95rem;
    }
    .chapter-title-name { font-size: 1.8rem; }

    /* テキストボックス内コントロール：モバイル */
    #textbox-controls {
        bottom: 6px;
        right: 10px;
        gap: 4px;
    }
    #textbox-controls button {
        font-size: 0.7rem;
        padding: 8px 10px;
        min-height: 40px;
        min-width: 40px;
    }

    /* カードバッジ：モバイル */
    #card-badge {
        top: 8px;
        right: 8px;
        padding: 4px 10px;
        font-size: 0.68rem;
    }

    /* メニューパネル：モバイル */
    #menu-panel {
        width: 260px;
        right: -260px;
    }
    .menu-panel-item {
        padding: 14px 20px;
        font-size: 0.88rem;
    }

    /* カードグリッド：モバイルは小さめ */
    .collection-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 0.5rem;
    }
    .card-icon { font-size: 1.2rem; }
    .card-title { font-size: 0.4rem; }
    .card-rank { font-size: 0.6rem; }
    .card-suit-small { font-size: 0.55rem; }
    .card-detail-layout {
        flex-direction: column;
        align-items: center;
    }
    .card-detail-card {
        flex: 0 0 auto;
        width: 140px;
    }
    .card-unlock-popup-card { width: 120px; }

    /* カード拡大ビューア：モバイル */
    .card-fullview-card {
        width: 75vmin;
        max-width: 320px;
    }
    .card-fullview-title { font-size: 1rem; }
    .card-fullview-card .garst-card-front .card-rank { font-size: 1.4rem; }
    .card-fullview-card .garst-card-front .card-suit-small { font-size: 1.2rem; }
    .card-fullview-card .garst-card-front .card-icon { font-size: 3rem; }
    .card-fullview-card .garst-card-front .card-title { font-size: 0.95rem; }

    /* セーブ/ロード画面：スマホでは Flexbox で1列固定（Grid の行高問題を回避） */
    .saveload-slots {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
        gap: 0.7rem;
        padding: 0.7rem;
    }
    .save-slot {
        min-height: auto;
        height: auto;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-sizing: border-box;
        overflow: hidden;
        flex-shrink: 0;
    }
    .save-slot.empty {
        min-height: 70px;
    }
    .save-slot-info {
        font-size: 0.85rem;
        line-height: 1.4;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .save-slot-empty-label {
        font-size: 0.8rem;
    }
    .save-slot-number {
        margin-bottom: 0.3rem;
    }
    .save-slot-date {
        margin-top: 0.3rem;
    }
}


@media (max-width: 480px) {
    .collection-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 0.4rem;
    }
    .collection-tabs { gap: 0.3rem; }
    .collection-tab {
        padding: 0.3rem 0.8rem;
        font-size: 0.75rem;
    }

    /* テキストボックス内コントロール：小画面 */
    #textbox-controls button {
        font-size: 0.65rem;
        padding: 7px 9px;
        min-height: 40px;
        min-width: 40px;
        letter-spacing: 0.06em;
    }

    /* メニューパネル：小画面 */
    #menu-panel {
        width: 240px;
        right: -240px;
    }

    .choice-btn {
        width: 92%;
    }

    /* カード拡大ビューア：小画面 */
    .card-fullview-card {
        width: 70vmin;
        max-width: 260px;
    }
}

/* ============================================
   カード入手トースト通知（右上）
   ============================================ */
.card-toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(10, 17, 40, 0.95);
    border: 1px solid var(--card-gold);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    box-shadow: 0 0 20px rgba(212, 168, 67, 0.4);
    animation: toastSlideIn 0.5s ease forwards;
    cursor: pointer;
}

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

@keyframes toastFadeOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-20px); }
}

.card-toast-mini {
    width: 40px;
    height: 56px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--card-gold);
    background: linear-gradient(180deg, #f5f0e8, #ede5d8);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.card-toast-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.card-toast-label {
    font-size: 0.65rem;
    color: var(--card-gold);
    letter-spacing: 0.2em;
}

.card-toast-title {
    font-size: 0.85rem;
    color: var(--color-accent-light);
    letter-spacing: 0.05em;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-toast-suit {
    font-size: 0.7rem;
    opacity: 0.6;
    color: var(--color-accent);
}

.card-toast:nth-child(2) { top: 5.5rem; }
.card-toast:nth-child(3) { top: 9.5rem; }

@media (max-width: 768px) {
    .card-toast {
        right: 0.5rem;
        top: 0.5rem;
        padding: 0.4rem 0.8rem;
    }
    .card-toast-mini {
        width: 32px;
        height: 45px;
        font-size: 1rem;
    }
    .card-toast-title {
        font-size: 0.75rem;
        max-width: 140px;
    }
}

/* ============================================
   ミニゲーム：ハイ＆ロー
   ============================================ */
.cardgame-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 250;
    background: rgba(5, 8, 20, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

.cardgame-container {
    width: 90%;
    max-width: 600px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cardgame-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.cardgame-title {
    font-size: 1.5rem;
    color: var(--card-gold);
    letter-spacing: 0.3em;
    font-weight: 700;
}

.cardgame-streak {
    font-size: 1.3rem;
    letter-spacing: 0.3em;
    color: var(--card-gold-light);
    min-height: 1.5em;
}

.cardgame-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 220px;
}

.cardgame-card-area {
    display: flex;
    justify-content: center;
    align-items: center;
}

.cardgame-card {
    width: 120px;
    height: 168px;
    background: linear-gradient(180deg, #f5f0e8, #ede5d8);
    border: 2px solid #888;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.6rem;
    position: relative;
}

.cardgame-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 700;
}

.cardgame-card-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.8rem;
}

.cardgame-card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 700;
    transform: rotate(180deg);
}

.cardgame-card-pair {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cardgame-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.cardgame-card-label {
    font-size: 0.7rem;
    color: var(--color-accent);
    opacity: 0.6;
}

.cardgame-vs {
    font-size: 1.5rem;
    color: var(--card-gold);
    margin: 0 0.3rem;
}

.cardgame-card-reveal {
    animation: cardReveal 0.5s ease;
}

@keyframes cardReveal {
    0%   { opacity: 0; transform: scale(0.5) rotateY(90deg); }
    60%  { opacity: 1; transform: scale(1.05) rotateY(0deg); }
    100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

.cardgame-message {
    font-size: 1rem;
    color: var(--color-text);
    min-height: 1.5em;
    letter-spacing: 0.05em;
}

.cardgame-correct { color: #4ecdc4; font-weight: 700; }
.cardgame-wrong { color: #e74c3c; font-weight: 700; }

.cardgame-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cardgame-btn {
    padding: 0.8rem 2rem;
    border: 1px solid var(--color-window-border);
    background: transparent;
    color: var(--color-text);
    font-family: var(--font-main);
    font-size: 1rem;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    min-height: 48px;
}

.cardgame-btn:hover {
    background: rgba(196, 149, 106, 0.2);
    border-color: var(--color-accent);
    color: var(--color-accent-light);
}

.cardgame-btn-high { border-color: #c0392b; color: #e74c3c; }
.cardgame-btn-high:hover { background: rgba(192, 57, 43, 0.2); border-color: #e74c3c; }
.cardgame-btn-low { border-color: #4a6fa5; color: #5dade2; }
.cardgame-btn-low:hover { background: rgba(74, 111, 165, 0.2); border-color: #5dade2; }
.cardgame-btn-skip { opacity: 0.6; font-size: 0.85rem; }
.cardgame-btn-skip:hover { opacity: 1; }
.cardgame-btn-start { border-color: var(--card-gold); color: var(--card-gold); }
.cardgame-btn-start:hover { background: rgba(212, 168, 67, 0.2); }

@media (max-width: 768px) {
    .cardgame-card { width: 90px; height: 126px; }
    .cardgame-card-center { font-size: 2rem; }
    .cardgame-btn { padding: 0.6rem 1.2rem; font-size: 0.9rem; }
    .cardgame-title { font-size: 1.2rem; }
}

/* ============================================
   神経衰弱（MemoryGame）
   ============================================ */
.memory-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 260;
    background: #050814;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
    overflow: hidden;
}

.memory-container {
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    overflow-y: auto;
}

.memory-header { text-align: center; }
.memory-title {
    font-size: 1.6rem;
    color: var(--color-accent);
    letter-spacing: 0.3em;
}
.memory-subtitle {
    font-size: 0.85rem;
    color: var(--color-accent-light);
    letter-spacing: 0.15em;
    margin-top: 0.2rem;
}

.memory-scores { display: flex; align-items: center; gap: 1.5rem; }
.memory-score { text-align: center; }
.memory-score-name { font-size: 0.8rem; color: var(--color-text); letter-spacing: 0.1em; opacity: 0.8; }
.memory-score-value { font-size: 2rem; font-weight: bold; color: var(--color-accent); line-height: 1; margin-top: 0.2rem; }
.memory-score-vs { font-size: 0.9rem; color: var(--color-window-border); letter-spacing: 0.1em; }
.memory-score-player .memory-score-value { color: #4a9fd5; }
.memory-score-laura .memory-score-value { color: #e07a8a; }

.memory-turn {
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    text-align: center;
}
.memory-turn-player { color: #4a9fd5; background: rgba(74, 159, 213, 0.1); border: 1px solid rgba(74, 159, 213, 0.3); }
.memory-turn-laura { color: #e07a8a; background: rgba(224, 122, 138, 0.1); border: 1px solid rgba(224, 122, 138, 0.3); }

.memory-board { display: grid; gap: 0.5rem; width: 100%; max-width: 480px; padding: 0.5rem; }

.memory-cell {
    aspect-ratio: 5 / 7;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-radius: 6px;
    overflow: hidden;
}
.memory-cell:hover:not(.matched):not(.flipped) { transform: translateY(-2px); }
.memory-cell.matched { opacity: 0.5; cursor: default; transform: none; }
.memory-cell.flipped { cursor: default; }

.memory-card-front {
    width: 100%; height: 100%;
    background: rgba(15, 20, 40, 0.95);
    border: 2px solid;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.3rem;
    box-sizing: border-box;
}
.memory-card-rank { font-size: 0.7rem; font-weight: bold; letter-spacing: 0.05em; width: 100%; text-align: left; padding-left: 0.2rem; }
.memory-card-icon { font-size: 1.4rem; line-height: 1; }
.memory-card-title { font-size: 0.5rem; color: var(--color-text); text-align: center; line-height: 1.2; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; padding: 0 0.2rem; }

.memory-card-back {
    width: 100%; height: 100%;
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(135deg, #1a2a4a 0%, #0d1528 100%);
    border: 2px solid var(--color-window-border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.memory-card-back img { width: 100%; height: 100%; object-fit: cover; }
.memory-card-back-fallback {
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-accent);
    background: linear-gradient(135deg, #1a2a4a 0%, #0d1528 100%);
}

.memory-message { text-align: center; min-height: 1.5rem; color: var(--color-text); font-size: 0.9rem; margin-bottom: 0.5rem; }
.memory-intro-text { font-size: 0.95rem; color: var(--color-text); line-height: 1.8; text-align: center; padding: 1rem 0; }
.memory-result { text-align: center; padding: 0.5rem 0; }
.memory-result-title { font-size: 1.2rem; color: var(--color-accent); letter-spacing: 0.1em; margin-bottom: 0.5rem; }
.memory-result-laura { font-size: 0.9rem; color: var(--color-text); line-height: 1.6; }
.memory-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; padding-bottom: 1.5rem; }

@media (max-width: 768px) {
    .memory-container { width: 95%; gap: 0.5rem; }
    .memory-title { font-size: 1.2rem; }
    .memory-score-value { font-size: 1.5rem; }
    .memory-scores { gap: 1rem; }
    .memory-board { gap: 0.4rem; padding: 0.3rem; }
    .memory-card-icon { font-size: 1.1rem; }
    .memory-card-title { font-size: 0.45rem; }
    .memory-card-rank { font-size: 0.6rem; }
}

@media (max-width: 480px) {
    .memory-container { width: 98%; gap: 0.4rem; }
    .memory-title { font-size: 1rem; }
    .memory-subtitle { font-size: 0.7rem; }
    .memory-score-value { font-size: 1.2rem; }
    .memory-board { gap: 0.3rem; padding: 0.2rem; }
    .memory-card-icon { font-size: 0.9rem; }
    .memory-card-title { display: none; }
    .memory-turn { font-size: 0.75rem; padding: 0.3rem 0.8rem; }
}

/* 神経衰弱：キーボードフォーカスリング */
.memory-cell:focus-visible {
    outline: 2px solid #a88c5a;
    outline-offset: 2px;
}
.memory-cell:focus:not(:focus-visible) {
    outline: none;
}


.memory-laura { text-align: center; margin: -0.5rem 0; }
.memory-laura img {
    height: 200px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
    transition: opacity 0.3s ease, transform 0.3s ease;
}
@media (max-width: 768px) { .memory-laura img { height: 150px; } }
@media (max-width: 480px) { .memory-laura img { height: 110px; } }

/* ============================================
   エンドクレジット（エンドロール）
   ============================================ */
.endcredits-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 300; background: #050814; animation: fadeIn 2s ease;
}
.ec-scroll-wrapper {
    width: 100%; height: 100%; overflow-y: auto;
    scrollbar-width: none; -ms-overflow-style: none;
}
.ec-scroll-wrapper::-webkit-scrollbar { display: none; }
.ec-scroll-content {
    max-width: 600px; margin: 0 auto; padding: 0 2rem;
    text-align: center; color: var(--color-text); line-height: 1.8;
}
.ec-spacer { height: 100vh; }
.ec-spacer-small { height: 30vh; }
.ec-spacer-large { height: 50vh; }
.ec-title-section { padding: 2rem 0; }
.ec-main-title { font-size: 2.4rem; color: var(--color-accent); letter-spacing: 0.15em; margin-bottom: 0.8rem; }
.ec-main-subtitle { font-size: 1rem; color: var(--color-accent-light); letter-spacing: 0.2em; }
.ec-message { font-size: 0.95rem; line-height: 2; color: var(--color-text); opacity: 0.9; }
.ec-message p { margin-bottom: 1.5rem; }
.ec-quote { padding: 2rem 0; }
.ec-quote-text { font-size: 1.6rem; color: var(--color-accent); font-style: italic; letter-spacing: 0.1em; margin-bottom: 0.8rem; }
.ec-quote-attr { font-size: 0.85rem; color: var(--color-accent-light); letter-spacing: 0.1em; }
.ec-section { padding: 1.5rem 0; }
.ec-heading { font-size: 1.1rem; color: var(--color-accent); letter-spacing: 0.3em; margin-bottom: 2rem; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(168, 140, 90, 0.3); }
.ec-body { margin-bottom: 1.5rem; font-size: 0.85rem; line-height: 1.8; }
.ec-body p { margin-bottom: 0.4rem; }
.ec-source-title { font-size: 0.95rem; color: var(--color-accent-light); font-weight: bold; margin-bottom: 0.3rem; }
.ec-url { font-size: 0.7rem; color: var(--color-window-border); word-break: break-all; opacity: 0.7; margin-top: 0.3rem; }
.ec-divider { width: 40px; height: 1px; background: rgba(168, 140, 90, 0.3); margin: 1.5rem auto; }
.ec-persons p { margin-bottom: 1.2rem; }
.ec-persons strong { color: var(--color-accent-light); letter-spacing: 0.05em; }
.ec-tribute { font-size: 0.95rem; line-height: 2.2; opacity: 0.9; }
.ec-credit-role { font-size: 0.8rem; color: var(--color-window-border); letter-spacing: 0.15em; margin-bottom: 0.3rem; }
.ec-credit-name { font-size: 1.1rem; color: var(--color-text); letter-spacing: 0.1em; }
.ec-final { padding: 3rem 0; }
.ec-final-text { font-size: 1.8rem; color: var(--color-accent); font-style: italic; letter-spacing: 0.1em; animation: ecGlow 3s ease-in-out infinite alternate; }
@keyframes ecGlow { 0% { opacity: 0.6; } 100% { opacity: 1; } }
/* --- 汎用ゲームボタン --- */
.game-btn {
    display: inline-block;
    padding: 0.9rem 2.5rem;
    background: transparent;
    border: 1px solid var(--color-window-border);
    color: var(--color-accent-light);
    font-family: var(--font-main);
    font-size: 1rem;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 48px;
    border-radius: 4px;
}
.game-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(196, 149, 106, 0.15), transparent);
    transition: left 0.5s ease;
}
.game-btn:hover {
    border-color: var(--color-accent);
    color: #fff;
    text-shadow: 0 0 8px rgba(196, 149, 106, 0.3);
    background: rgba(196, 149, 106, 0.1);
}
.game-btn:hover::before {
    left: 100%;
}
.game-btn:active {
    transform: scale(0.97);
}
.ec-end-buttons { text-align: center; padding: 1rem 0; }


@media (max-width: 768px) {
    .ec-scroll-content { padding: 0 1.5rem; }
    .ec-main-title { font-size: 1.8rem; }
    .ec-quote-text { font-size: 1.3rem; }
    .ec-final-text { font-size: 1.4rem; }
    .ec-spacer { height: 80vh; }
}
@media (max-width: 480px) {
    .ec-scroll-content { padding: 0 1rem; }
    .ec-main-title { font-size: 1.4rem; }
    .ec-main-subtitle { font-size: 0.85rem; }
    .ec-quote-text { font-size: 1.1rem; }
    .ec-message { font-size: 0.85rem; }
    .ec-final-text { font-size: 1.2rem; }
    .ec-spacer { height: 60vh; }
    .ec-spacer-small { height: 20vh; }
}

/* ============================================
   ロックカード表示（シルエット＋ランク）
   ============================================ */
.garst-card-locked {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 0.4rem;
    background: rgba(20, 18, 14, 0.95);
    border: 1px solid rgba(168, 140, 90, 0.15);
    border-radius: 6px; position: relative; overflow: hidden;
}
.garst-card-locked::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(168, 140, 90, 0.03) 8px, rgba(168, 140, 90, 0.03) 16px);
    pointer-events: none;
}
.card-locked-header { display: flex; align-items: center; gap: 0.15rem; }
.card-locked-footer { display: flex; align-items: center; gap: 0.15rem; justify-content: flex-end; transform: rotate(180deg); }
.card-locked-rank { font-size: 0.7rem; color: rgba(168, 140, 90, 0.35); font-weight: bold; }
.card-locked-suit { font-size: 0.65rem; color: rgba(168, 140, 90, 0.25); }
.garst-card-locked.suit-heart .card-locked-suit,
.garst-card-locked.suit-diamond .card-locked-suit { color: rgba(180, 60, 60, 0.25); }
.garst-card-locked.suit-heart .card-locked-rank,
.garst-card-locked.suit-diamond .card-locked-rank { color: rgba(180, 60, 60, 0.35); }
.card-locked-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card-locked-question { font-size: 1.8rem; color: rgba(168, 140, 90, 0.2); font-weight: bold; line-height: 1; }
.card-locked-hint {
    font-size: 0.5rem; color: rgba(168, 140, 90, 0.3); margin-top: 0.3rem;
    letter-spacing: 0.1em; border: 1px solid rgba(168, 140, 90, 0.15);
    padding: 0.1rem 0.4rem; border-radius: 2px;
}

/* ============================================
   カード取り逃しゴースト演出
   ============================================ */
.missed-card-ghost {
    position: fixed; right: -80px; top: 50%; transform: translateY(-50%);
    z-index: 500; animation: missedCardSlide 3.3s ease forwards; pointer-events: none;
}
.missed-card-inner {
    width: 60px; height: 84px;
    background: rgba(20, 18, 14, 0.9); border: 1px solid rgba(168, 140, 90, 0.4);
    border-radius: 6px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 0.2rem;
    box-shadow: 0 0 20px rgba(168, 140, 90, 0.15);
}
.missed-card-suit { font-size: 0.8rem; color: rgba(168, 140, 90, 0.5); }
.missed-card-rank { font-size: 0.7rem; color: rgba(168, 140, 90, 0.4); font-weight: bold; }
.missed-card-label { font-size: 1.2rem; color: rgba(168, 140, 90, 0.3); font-weight: bold; }

@keyframes missedCardSlide {
    0% { right: -80px; opacity: 0; }
    15% { right: 20px; opacity: 0.8; }
    70% { right: 20px; opacity: 0.6; }
    100% { right: 20px; opacity: 0; }
}
.missed-card-ghost.fading { animation: missedCardFadeOut 0.8s ease forwards; }
@keyframes missedCardFadeOut {
    from { right: 20px; opacity: 0.6; }
    to { right: 20px; opacity: 0; }
}

/* ============================================
   タイトル画面クレジット
   ============================================ */
.title-credit {
    position: absolute; bottom: 2rem; left: 0; width: 100%;
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    pointer-events: none;
}
.credit-org { font-size: 0.75rem; color: rgba(168, 140, 90, 0.5); letter-spacing: 0.25em; }
.credit-year { font-size: 0.65rem; color: rgba(168, 140, 90, 0.35); letter-spacing: 0.4em; }

/* ============================================
   タイトル画面 言語切替スイッチ
   ============================================ */
.title-lang-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.4rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid rgba(168, 140, 90, 0.35);
    border-radius: 999px;
    background: rgba(20, 15, 10, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.title-lang-btn {
    background: transparent;
    border: none;
    color: rgba(232, 203, 168, 0.55);
    font-family: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    border-radius: 999px;
    transition: color 0.25s ease, background 0.25s ease, transform 0.15s ease;
    min-height: 36px;
}
.title-lang-btn:hover {
    color: var(--color-accent-light);
    background: rgba(196, 149, 106, 0.12);
}
.title-lang-btn:active {
    transform: scale(0.97);
}
.title-lang-btn.active {
    color: var(--color-bg);
    background: var(--color-accent);
    font-weight: 700;
    box-shadow: 0 0 12px rgba(196, 149, 106, 0.35);
}
.title-lang-sep {
    color: rgba(168, 140, 90, 0.4);
    font-size: 0.85rem;
    user-select: none;
}
@media (max-width: 480px) {
    .title-lang-switch { margin-top: 1.1rem; padding: 0.3rem 0.7rem; gap: 0.4rem; }
    .title-lang-btn { font-size: 0.78rem; padding: 0.25rem 0.55rem; min-height: 34px; }
}

/* ============================================
   プレイヤー入力欄
   ============================================ */
.player-input-container {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.8rem; padding: 1.5rem; max-width: 480px; margin: 0 auto;
}
.player-input-textarea {
    width: 100%; min-height: 80px; max-height: 120px; padding: 0.8rem;
    background: rgba(20, 18, 14, 0.9); border: 1px solid rgba(168, 140, 90, 0.4);
    border-radius: 6px; color: var(--color-text); font-family: 'Shippori Mincho', serif;
    font-size: 0.95rem; line-height: 1.6; resize: none; outline: none;
    transition: border-color 0.3s ease;
}
.player-input-textarea::placeholder { color: rgba(168, 140, 90, 0.6); font-style: italic; }

.player-input-textarea:focus { border-color: rgba(168, 140, 90, 0.7); }
.player-input-charcount { font-size: 0.65rem; color: rgba(168, 140, 90, 0.4); align-self: flex-end; letter-spacing: 0.05em; }
.player-input-buttons { display: flex; gap: 0.8rem; width: 100%; }
.player-input-submit { flex: 1; }
.player-input-skip { flex: 1; opacity: 0.6; }
.player-input-skip:hover { opacity: 0.8; }

/* ============================================
   コレクション画面：あなたのメッセージ表示
   ============================================ */
.player-message-display { margin-top: 2rem; padding: 1.5rem; text-align: center; border-top: 1px solid rgba(168, 140, 90, 0.15); }
.player-message-label { font-size: 0.7rem; color: rgba(168, 140, 90, 0.45); letter-spacing: 0.2em; margin-bottom: 0.8rem; }
.player-message-text { font-size: 1rem; color: rgba(168, 140, 90, 0.7); line-height: 1.8; font-style: italic; }

/* ============================================
   デモプレイヤー — 映画予告編スタイル
   ============================================ */
.demo-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 500; opacity: 0; transition: opacity 0.8s ease;
    pointer-events: none; overflow: hidden;
}
.demo-overlay.visible { opacity: 1; pointer-events: auto; }

.demo-bg-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center; background-repeat: no-repeat;
    transition: opacity 1.2s ease;
    animation: demo-ken-burns 12s ease-in-out infinite alternate;
    filter: brightness(0.25) saturate(0.5);
}
#demo-bg { opacity: 1; z-index: 1; }
#demo-bg-next { opacity: 0; z-index: 2; }
@keyframes demo-ken-burns { 0% { transform: scale(1.0); } 100% { transform: scale(1.08); } }

.demo-vignette {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 3;
    background:
        linear-gradient(rgba(10, 8, 5, 0.55), rgba(10, 8, 5, 0.55)),
        radial-gradient(ellipse at center, rgba(10, 8, 5, 0) 0%, rgba(10, 8, 5, 0.4) 50%, rgba(10, 8, 5, 0.9) 100%);
    pointer-events: none;
}

.demo-content {
    position: relative; z-index: 4; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.demo-slide-container {
    flex: 1; display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 2rem; cursor: pointer;
}
.demo-slide {
    text-align: center; opacity: 0; transition: opacity 0.8s ease;
    max-width: 640px; width: 100%; min-height: 120px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem;
}
.demo-slide.visible { opacity: 1; }

.demo-line {
    font-size: 1.15rem; line-height: 2; color: #d4c8b0;
    letter-spacing: 0.08em; font-feature-settings: "palt";
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}
.demo-style-quote .demo-line { font-size: 1.1rem; color: #c8b88a; font-style: italic; line-height: 2.2; }
.demo-style-final-quote .demo-line { font-size: 1.6rem; color: #a88c5a; font-style: italic; letter-spacing: 0.06em; line-height: 2; }
.demo-style-numbers .demo-line { font-size: 1.05rem; color: #8a7e6e; letter-spacing: 0.1em; line-height: 2.4; }
.demo-style-title .demo-line:first-child { font-size: 2rem; color: #a88c5a; letter-spacing: 0.15em; font-weight: bold; line-height: 1.6; margin-bottom: 0.5rem; }
.demo-style-title .demo-line:nth-child(2) { font-size: 0.95rem; color: #8a7e6e; letter-spacing: 0.1em; line-height: 1.8; }

.demo-start-area { padding: 1.5rem 0 2.5rem; text-align: center; z-index: 5; }
.demo-start-btn {
    background: rgba(10, 8, 5, 0.6); border: 1px solid rgba(168, 140, 90, 0.3);
    color: #a88c5a; font-size: 0.95rem; padding: 0.8rem 2.5rem; border-radius: 4px;
    cursor: pointer; letter-spacing: 0.18em; transition: all 0.4s ease;
    font-family: inherit; position: relative;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    min-height: 48px;
}
.demo-start-btn:hover { background: rgba(168, 140, 90, 0.12); border-color: rgba(168, 140, 90, 0.6); box-shadow: 0 0 24px rgba(168, 140, 90, 0.15); }
.demo-start-btn:active { transform: scale(0.97); }
.demo-start-btn::after {
    content: ''; position: absolute; top: -1px; left: -1px; right: -1px; bottom: -1px;
    border: 1px solid rgba(168, 140, 90, 0); border-radius: 4px;
    animation: demo-btn-breathe 3.5s ease-in-out infinite; pointer-events: none;
}
@keyframes demo-btn-breathe {
    0%, 100% { border-color: rgba(168, 140, 90, 0); transform: scale(1); }
    50% { border-color: rgba(168, 140, 90, 0.25); transform: scale(1.015); }
}
.demo-start-text { position: relative; z-index: 1; }

@media (max-width: 600px) {
    .demo-line { font-size: 1rem; line-height: 1.9; }
    .demo-style-final-quote .demo-line { font-size: 1.25rem; }
    .demo-style-title .demo-line:first-child { font-size: 1.5rem; }
    .demo-style-title .demo-line:nth-child(2) { font-size: 0.85rem; }
    .demo-style-quote .demo-line { font-size: 0.95rem; }
    .demo-start-btn { font-size: 0.85rem; padding: 0.7rem 2rem; }
    .demo-slide-container { padding: 1.5rem 1rem; }
    .demo-slide { min-height: 80px; }
}
@media (max-width: 380px) {
    .demo-line { font-size: 0.9rem; }
    .demo-style-final-quote .demo-line { font-size: 1.1rem; }
    .demo-style-title .demo-line:first-child { font-size: 1.3rem; }
}

/* ============================================
   アクセシビリティ
   ============================================ */
.choice-btn:focus-visible,
.title-btn:focus-visible,
.game-menu-btn:focus-visible,
.close-btn:focus-visible,
.collection-tab:focus-visible,
.save-slot:focus-visible,
.garst-card.unlocked:focus-visible,
.game-btn:focus-visible,
#error-retry-btn:focus-visible,
#error-title-btn:focus-visible,
#btn-ec-title:focus-visible,
.save-slot-delete:focus-visible,
#textbox-controls button:focus-visible,
.menu-panel-item:focus-visible,
.menu-panel-close:focus-visible,
#card-badge:focus-visible,
.card-fullview-close:focus-visible {
    outline: 2px solid #a88c5a;
    outline-offset: 3px;
}

.choice-btn:focus:not(:focus-visible),
.title-btn:focus:not(:focus-visible),
.game-menu-btn:focus:not(:focus-visible),
.close-btn:focus:not(:focus-visible),
.collection-tab:focus:not(:focus-visible),
.save-slot:focus:not(:focus-visible),
.garst-card.unlocked:focus:not(:focus-visible),
.game-btn:focus:not(:focus-visible),
.save-slot-delete:focus:not(:focus-visible),
#textbox-controls button:focus:not(:focus-visible),
.menu-panel-item:focus:not(:focus-visible),
.menu-panel-close:focus:not(:focus-visible),
#card-badge:focus:not(:focus-visible),
.card-fullview-close:focus:not(:focus-visible) {
    outline: none;
}

input[type="range"]:focus-visible { outline: 2px solid #a88c5a; outline-offset: 2px; }
input[type="range"]:focus:not(:focus-visible) { outline: none; }
.player-input-textarea:focus-visible { outline: 2px solid #a88c5a; outline-offset: 2px; }
.player-input-textarea:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .chapter-title-overlay { transition: opacity 0.01ms !important; }
    .bg-layer { transition: opacity 0.01ms !important; }
    .chara-img { transition: opacity 0.01ms !important; transform: none !important; }
    .card-toast { animation: none !important; }
    .missed-card-ghost { animation: none !important; }
    #menu-panel { transition: right 0.01ms !important; }
    #menu-overlay { transition: opacity 0.01ms !important; }
    .card-fullview-overlay { animation: none !important; }
    .card-fullview-card { animation: none !important; }
    .card-fullview-info { animation: none !important; }
    .card-fullview-hint { animation: none !important; }
    .card-fullview-overlay.closing { animation: none !important; }
}

@media (forced-colors: active) {
    .choice-btn, .title-btn, .game-menu-btn, .game-btn { border: 1px solid ButtonText; }
    .text-window { border: 1px solid CanvasText; }
    .save-slot { border: 1px solid CanvasText; }
    .garst-card { border: 1px solid CanvasText; }
    .collection-progress-bar { border: 1px solid CanvasText; }
    .collection-progress-fill { background: Highlight; }
    .collection-tab { border: 1px solid ButtonText; }
    .collection-tab.active { border: 2px solid Highlight; }
    .close-btn { border: 1px solid ButtonText; }
    #error-retry-btn, #error-title-btn { border: 1px solid ButtonText !important; }
    #textbox-controls button { border: 1px solid ButtonText; }
    .menu-panel-item { border-bottom: 1px solid CanvasText; }
    #card-badge { border: 1px solid ButtonText; }
    .card-fullview-close { border: 1px solid ButtonText; }
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

@media (prefers-contrast: more) {
    .text-body { color: #fff; }
    .speaker-name { color: #ffd700; }
    .game-menu-btn { color: #e8e0d0; }
    .backlog-text { color: #fff; }
    .save-slot-info { color: #e8e0d0; }
    .card-detail-content { color: #fff; }
    #textbox-controls button { color: rgba(232, 203, 168, 0.7); }
    .menu-panel-item { color: #e8e0d0; }
    #card-badge { color: rgba(212, 168, 67, 0.85); }
}

/* ============================================
   ミニゲーム演出強化（追加CSS）
   ============================================ */

/* --- 共通：紙吹雪パーティクル --- */
.effect-confetti {
    position: absolute;
    top: -10px;
    left: var(--x);
    width: 8px;
    height: 8px;
    background: var(--color);
    border-radius: 50%;
    animation: confetti-fall 1.8s ease-out var(--delay) forwards;
    pointer-events: none;
    z-index: 100;
}
@keyframes confetti-fall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    70%  { opacity: 0.8; }
    100% { opacity: 0; transform: translateY(350px) rotate(720deg) scale(0.3); }
}

/* --- ハイ＆ロー：台詞吹き出し --- */
.cardgame-dialogue {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.6rem 1rem;
    margin-top: 0.5rem;
    background: rgba(20, 15, 10, 0.7);
    border-left: 3px solid var(--color-accent);
    border-radius: 4px;
    animation: cg-dialogue-in 0.4s ease;
}
@keyframes cg-dialogue-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cardgame-dialogue-speaker {
    font-size: 0.75rem;
    color: var(--color-accent);
    letter-spacing: 0.15em;
}
.cardgame-dialogue-text {
    font-size: 0.95rem;
    color: var(--color-text);
    line-height: 1.6;
}
.cardgame-rule-text {
    font-size: 0.85rem;
    color: var(--color-text);
    opacity: 0.7;
    margin-top: 0.8rem;
}

/* --- ハイ＆ロー：カード登場アニメーション --- */
.cardgame-card-entrance {
    animation: cg-card-entrance 0.5s ease;
}
@keyframes cg-card-entrance {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- ハイ＆ロー：正解カード発光 --- */
.cg-card-correct {
    animation: cg-glow 0.8s ease;
}
@keyframes cg-glow {
    0%   { box-shadow: 0 0 0 rgba(78, 205, 196, 0); }
    50%  { box-shadow: 0 0 25px rgba(78, 205, 196, 0.6); }
    100% { box-shadow: 0 0 0 rgba(78, 205, 196, 0); }
}

/* --- ハイ＆ロー：不正解カード揺れ --- */
.cg-card-wrong {
    animation: cg-shake 0.4s ease;
}
@keyframes cg-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

/* --- ハイ＆ロー：星パルス --- */
.cg-streak-pulse {
    animation: cg-streak-pulse 0.5s ease;
}
@keyframes cg-streak-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* --- 神経衰弱：3Dカードフリップ --- */
.memory-cell {
    perspective: 600px;
}
.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
}
.memory-card-inner.flipped {
    transform: rotateY(180deg);
}
.memory-card-inner > .memory-card-back,
.memory-card-inner > .memory-card-front {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    backface-visibility: hidden;
}
.memory-card-inner > .memory-card-front {
    transform: rotateY(180deg);
}

/* --- 神経衰弱：マッチ成立バウンス --- */
.memory-cell.matched .memory-card-inner {
    transform: rotateY(180deg);
    animation: mg-match-bounce 0.5s ease;
}
@keyframes mg-match-bounce {
    0%   { transform: rotateY(180deg) scale(1); }
    50%  { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* --- 神経衰弱：マッチ後の光彩 --- */
.memory-cell.matched::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 8px;
    border: 2px solid rgba(212, 168, 67, 0.4);
    animation: mg-match-glow 2s ease infinite;
    pointer-events: none;
}
@keyframes mg-match-glow {
    0%, 100% { border-color: rgba(212, 168, 67, 0.2); }
    50%      { border-color: rgba(212, 168, 67, 0.6); }
}

/* --- 神経衰弱：ローラの台詞表示 --- */
.memory-laura-line {
    color: #d4c5a0;
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
    padding: 0.5rem 1rem;
    background: rgba(26, 21, 15, 0.8);
    border-left: 3px solid #c0392b;
    border-radius: 4px;
    min-height: 2.2em;
    animation: mg-laura-line-in 0.4s ease;
}
@keyframes mg-laura-line-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- prefers-reduced-motion 対応 --- */
@media (prefers-reduced-motion: reduce) {
    .effect-confetti { animation: none !important; display: none; }
    .cardgame-card-entrance { animation: none !important; }
    .cg-card-correct { animation: none !important; }
    .cg-card-wrong { animation: none !important; }
    .cg-streak-pulse { animation: none !important; }
    .cardgame-dialogue { animation: none !important; }
    .memory-card-inner { transition: none !important; }
    .mg-match-bounce { animation: none !important; }
    .memory-cell.matched::after { animation: none !important; }
    .memory-laura-line { animation: none !important; }
}

/* ============================================
   エンドクレジット：自動スクロール再開ボタン
   ============================================ */
#ec-resume-btn {
    box-shadow: 0 0 20px rgba(168, 140, 90, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(10, 8, 5, 0.85);
}

#ec-resume-btn:hover {
    box-shadow: 0 0 30px rgba(168, 140, 90, 0.35);
}

#ec-resume-btn:focus-visible {
    outline: 2px solid #a88c5a;
    outline-offset: 3px;
}

#ec-resume-btn:focus:not(:focus-visible) {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    #ec-resume-btn {
        transition: none !important;
    }
}

@media (max-width: 480px) {
    #ec-resume-btn {
        font-size: 0.7rem;
        padding: 0.5rem 1.2rem;
        bottom: 1rem;
    }
}
/* ============================================
   多言語対応：英語時のフォント切替
   ============================================ */

/* 英語版用フォントの読み込み */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,600;1,400&display=swap');

/* 英語選択時のフォント切替 */
html[data-lang="en"] body {
    font-family: 'EB Garamond', 'Noto Serif JP', serif;
}

html[data-lang="en"] .title-main {
    font-family: 'EB Garamond', serif;
    letter-spacing: 0.08em;
}

html[data-lang="en"] .title-sub {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    letter-spacing: 0.15em;
}

html[data-lang="en"] .title-btn,
html[data-lang="en"] .choice-btn,
html[data-lang="en"] .game-btn {
    letter-spacing: 0.1em;
}

html[data-lang="en"] .text-body {
    font-family: 'EB Garamond', 'Noto Serif JP', serif;
    letter-spacing: 0.02em;
}

html[data-lang="en"] .speaker-name {
    font-family: 'EB Garamond', serif;
    letter-spacing: 0.1em;
}

html[data-lang="en"] .chapter-title-name,
html[data-lang="en"] .chapter-title-keyword {
    font-family: 'EB Garamond', serif;
    letter-spacing: 0.1em;
}

html[data-lang="en"] .ec-main-title,
html[data-lang="en"] .ec-quote-text,
html[data-lang="en"] .ec-final-text {
    font-family: 'EB Garamond', serif;
}

/* 言語選択セレクター */
.setting-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c4956a' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 14px;
    padding-right: 2rem !important;
    cursor: pointer;
}

.setting-select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.setting-select option {
    background: #1a1410;
    color: var(--color-text);
}

/* ============================================
   初回操作チュートリアルガイド
   ============================================ */

.tutorial-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 9000;
    pointer-events: auto;
    cursor: pointer;
    animation: tutorialFadeIn 0.4s ease;
}

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

.tutorial-overlay.fading-out {
    animation: tutorialFadeOut 0.4s ease forwards;
}

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

/* 全体を薄暗くするレイヤー */
.tutorial-dim {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

/* スポットライト(対象ボタンを浮かび上がらせる枠) */
.tutorial-spotlight {
    position: absolute;
    border: 2px solid rgba(212, 168, 67, 0.95);
    border-radius: 8px;
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.55),
        0 0 24px rgba(212, 168, 67, 0.6),
        inset 0 0 12px rgba(212, 168, 67, 0.25);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    animation: tutorialPulse 2s ease-in-out infinite;
}

@keyframes tutorialPulse {
    0%, 100% { box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.55),
        0 0 24px rgba(212, 168, 67, 0.6),
        inset 0 0 12px rgba(212, 168, 67, 0.25); }
    50%      { box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.55),
        0 0 36px rgba(212, 168, 67, 0.9),
        inset 0 0 18px rgba(212, 168, 67, 0.4); }
}

/* ツールチップ */
.tutorial-tooltip {
    position: absolute;
    background: linear-gradient(180deg,
        rgba(30, 22, 15, 0.98) 0%,
        rgba(20, 15, 10, 0.98) 100%);
    border: 1px solid rgba(212, 168, 67, 0.6);
    border-radius: 8px;
    padding: 0.9rem 1.2rem;
    max-width: 280px;
    min-width: 200px;
    opacity: 0;
    transition: opacity 0.4s ease;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(212, 168, 67, 0.15);
    pointer-events: none;
    font-family: var(--font-main);
}

.tutorial-tooltip.measuring {
    opacity: 0;
    visibility: hidden;
    display: block;
}

.tutorial-tooltip.visible {
    opacity: 1;
}

.tutorial-tooltip-text {
    color: #e8cfa0;
    font-size: 0.9rem;
    line-height: 1.7;
    letter-spacing: 0.05em;
    text-align: center;
}

/* 矢印 */
.tutorial-tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translateX(-50%);
}

.tutorial-tooltip-arrow.arrow-bottom {
    bottom: -8px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(212, 168, 67, 0.6);
}

.tutorial-tooltip-arrow.arrow-top {
    top: -8px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid rgba(212, 168, 67, 0.6);
}

/* スキップヒント */
.tutorial-skip-hint {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(212, 168, 67, 0.55);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    font-family: var(--font-main);
    pointer-events: none;
    animation: tutorialHintBlink 2.5s ease-in-out infinite;
}

@keyframes tutorialHintBlink {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.85; }
}

/* チュートリアル操作ボタン */
.tutorial-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 90px));
    display: flex;
    gap: 0.8rem;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 2;
}

.tutorial-controls.visible {
    opacity: 1;
    pointer-events: auto;
}

.tutorial-btn {
    background: rgba(20, 15, 10, 0.85);
    border: 1px solid rgba(212, 168, 67, 0.5);
    border-radius: 6px;
    color: rgba(232, 207, 160, 0.9);
    font-family: var(--font-main);
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    padding: 0.6rem 1.4rem;
    cursor: pointer;
    transition: all 0.25s ease;
    min-height: 44px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tutorial-btn:hover:not(.disabled):not(:disabled) {
    background: rgba(212, 168, 67, 0.18);
    border-color: rgba(212, 168, 67, 0.85);
    color: #f5e0b8;
    box-shadow: 0 0 16px rgba(212, 168, 67, 0.25);
}

.tutorial-btn:active:not(.disabled):not(:disabled) {
    transform: scale(0.97);
}

.tutorial-btn-skip {
    opacity: 0.65;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    padding: 0.55rem 1.1rem;
}

.tutorial-btn-skip:hover:not(.disabled):not(:disabled) {
    opacity: 1;
}

.tutorial-btn.disabled,
.tutorial-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    border-color: rgba(212, 168, 67, 0.2);
}

.tutorial-btn-continue {
    background: rgba(212, 168, 67, 0.22);
    border-color: rgba(212, 168, 67, 0.7);
    color: #f5e0b8;
    font-weight: 500;
}

.tutorial-btn-counter {
    font-size: 0.7rem;
    opacity: 0.6;
    letter-spacing: 0.1em;
    margin-left: 0.2rem;
}

@media (max-width: 480px) {
    .tutorial-controls {
        transform: translate(-50%, calc(-50% + 80px));
        gap: 0.6rem;
    }
    .tutorial-btn {
        font-size: 0.78rem;
        padding: 0.5rem 1.1rem;
        letter-spacing: 0.1em;
    }
    .tutorial-btn-skip {
        font-size: 0.72rem;
        padding: 0.45rem 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tutorial-controls {
        transition: opacity 0.01ms !important;
    }
    .tutorial-btn {
        transition: none !important;
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    .tutorial-tooltip {
        max-width: 240px;
        min-width: 180px;
        padding: 0.7rem 1rem;
    }
    .tutorial-tooltip-text {
        font-size: 0.82rem;
        line-height: 1.6;
    }
    .tutorial-skip-hint {
        font-size: 0.7rem;
        bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .tutorial-tooltip {
        max-width: 200px;
        min-width: 160px;
    }
    .tutorial-tooltip-text {
        font-size: 0.78rem;
    }
}

/* prefers-reduced-motion 対応 */
@media (prefers-reduced-motion: reduce) {
    .tutorial-overlay,
    .tutorial-overlay.fading-out,
    .tutorial-spotlight,
    .tutorial-skip-hint {
        animation: none !important;
        transition: opacity 0.01ms !important;
    }
    .tutorial-tooltip {
        transition: opacity 0.01ms !important;
    }
}

/* ハイコントラストモード */
@media (forced-colors: active) {
    .tutorial-tooltip {
        border: 2px solid ButtonText;
    }
    .tutorial-spotlight {
        border: 2px solid Highlight;
    }
}

/* ============================================
   章ローディングオーバーレイ — 明治浪漫・水彩テーマ
   ============================================ */
.chapter-loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(
        135deg,
        rgba(10, 8, 5, 0.96) 0%,
        rgba(26, 20, 16, 0.96) 50%,
        rgba(10, 8, 5, 0.96) 100%
    );
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 8500;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: auto;
}
.chapter-loading-overlay.visible {
    opacity: 1;
}
.chapter-loading-overlay.hidden {
    display: none;
}

.chapter-loading-inner {
    text-align: center;
    max-width: 480px;
    width: 85%;
    padding: 2rem;
    animation: chapterLoadingFadeIn 0.8s ease;
}

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

.chapter-loading-title {
    font-size: 1.3rem;
    color: var(--color-accent-light);
    letter-spacing: 0.25em;
    margin-bottom: 0.6rem;
    text-shadow: 0 2px 15px rgba(196, 149, 106, 0.25);
}

.chapter-loading-subtitle {
    font-size: 0.85rem;
    color: var(--color-accent);
    letter-spacing: 0.15em;
    opacity: 0.7;
    margin-bottom: 2rem;
}

.chapter-loading-progress {
    margin-bottom: 1rem;
}

.chapter-loading-bar {
    width: 100%;
    height: 3px;
    background: rgba(168, 140, 90, 0.12);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.8rem;
    position: relative;
}

.chapter-loading-fill {
    height: 100%;
    background: linear-gradient(90deg,
        rgba(196, 149, 106, 0.4) 0%,
        rgba(232, 203, 168, 0.9) 50%,
        rgba(196, 149, 106, 0.4) 100%);
    background-size: 200% 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: chapterLoadingShimmer 2s linear infinite;
}

@keyframes chapterLoadingShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.chapter-loading-percent {
    font-size: 0.8rem;
    color: var(--color-accent);
    letter-spacing: 0.2em;
    opacity: 0.65;
}

.chapter-loading-counter {
    font-size: 0.7rem;
    color: var(--color-window-border);
    letter-spacing: 0.15em;
    opacity: 0.5;
    margin-bottom: 1.5rem;
}

.chapter-loading-hint {
    font-size: 0.75rem;
    color: var(--color-accent);
    letter-spacing: 0.15em;
    opacity: 0.5;
    font-style: italic;
    animation: chapterLoadingHintBlink 2.5s ease-in-out infinite;
}

@keyframes chapterLoadingHintBlink {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 0.7; }
}

/* モバイル対応 */
@media (max-width: 600px) {
    .chapter-loading-title {
        font-size: 1.05rem;
        letter-spacing: 0.18em;
    }
    .chapter-loading-subtitle {
        font-size: 0.75rem;
    }
    .chapter-loading-inner {
        padding: 1.5rem;
    }
}

@media (max-width: 380px) {
    .chapter-loading-title {
        font-size: 0.95rem;
    }
    .chapter-loading-subtitle {
        font-size: 0.7rem;
    }
}

/* モーション軽減対応 */
@media (prefers-reduced-motion: reduce) {
    .chapter-loading-inner,
    .chapter-loading-fill,
    .chapter-loading-hint {
        animation: none !important;
    }
    .chapter-loading-overlay {
        transition: opacity 0.01ms !important;
    }
}

/* ハイコントラストモード */
@media (forced-colors: active) {
    .chapter-loading-bar {
        border: 1px solid CanvasText;
    }
    .chapter-loading-fill {
        background: Highlight;
    }
}
