/* ==========================================
   名画で間違い探し ｜ スタイルシート
   テーマ：「小さな美術館・ギャラリー」
   ========================================== */

/* ------------------------------------------
   フォントのローカル読み込み (@font-face)
   ------------------------------------------ */
@font-face {
    font-family: 'Shippori Mincho';
    src: url('./public/fonts/shippori-mincho-regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Shippori Mincho';
    src: url('./public/fonts/shippori-mincho-700.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Noto Sans JP';
    src: url('./public/fonts/noto-sans-jp-regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Noto Sans JP';
    src: url('./public/fonts/noto-sans-jp-700.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

:root {
    /* 美術館テーマの配色設定 */
    --bg-primary: #F6F2E9;          /* 生成り（アイボリー） */
    --bg-card: #FCFAF5;             /* マット紙（明るい生成り） */
    --text-main: #2E2B26;           /* 墨色 */
    --text-muted: #6B655A;          /* 薄墨 */
    --color-accent: #B5493A;        /* 朱色 */
    
    --border-color: #D6CFC4;        /* 落ち着いた薄い罫線 */
    --frame-color: #423E37;         /* 額縁枠色 */

    --border-radius: 8px;           /* 角丸は最大8px */
    --card-shadow: 0 4px 12px rgba(46, 43, 38, 0.06); /* ごく薄い影1段 */
    
    --font-heading: 'Shippori Mincho', 'Georgia', serif;
    --font-body: 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
}

/* 高コントラストモード */
body.high-contrast {
    --bg-primary: #1E1C1A;          /* 極めて暗い墨色 */
    --bg-card: #0D0C0B;             /* 純黒に近い暗部 */
    --text-main: #FCFAF5;           /* 純白に近い生成り */
    --text-muted: #D6CFC4;          /* 明るめの薄墨 */
    --color-accent: #FF5A43;        /* 視認性を高めた明るい朱色 */
    
    --border-color: #6B655A;
    --frame-color: #FCFAF5;
}

/* ------------------------------------------
   基本設定
   ------------------------------------------ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.7;
    font-size: 18px; /* シニア向け基準 */
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#app-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
    min-height: 100vh;
    position: relative;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    #app-container {
        max-width: 600px;
    }
}

/* ヘッダー */
#main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 8px;
}

.logo-sub {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.logo-title {
    font-family: var(--font-heading);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-top: 2px;
    white-space: nowrap;
}

.header-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--text-main);
    border-radius: var(--border-radius);
    background-color: transparent;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    min-height: 44px;
    white-space: nowrap;
}

.control-btn:active {
    opacity: 0.7;
}

.icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 画面共通 */
.screen {
    display: none;
    flex-direction: column;
    flex: 1;
    padding: 24px 20px;
}

.screen.active {
    display: flex;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
}

/* ------------------------------------------
   額装風デザイン (Museum Frame)
   ------------------------------------------ */
.frame-container {
    padding: 8px;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.museum-frame {
    border: 4px solid var(--frame-color);
    background-color: #FFF;
    padding: 16px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    width: 100%;
}

body.high-contrast .museum-frame {
    background-color: var(--bg-card);
    border: 2px solid var(--text-main);
}

.museum-mat {
    background-color: #FCFAF5;
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

.hero-mat-image {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    display: block;
}

/* ------------------------------------------
   トップ画面
   ------------------------------------------ */
#screen-top {
    justify-content: space-between;
    gap: 32px;
}

.museum-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(46, 43, 38, 0.03);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.streak-badge {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-accent);
}

.collection-stats {
    font-size: 15px;
    font-weight: 700;
}

.top-hero {
    text-align: center;
}

.hero-tagline {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.hero-desc {
    font-size: 16px;
    color: var(--text-muted);
    padding: 0 8px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--text-main);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    min-height: 80px;
}

.menu-btn:active {
    transform: scale(0.98);
}

.primary-btn {
    background-color: var(--color-accent);
    color: #FCFAF5;
    border-color: var(--color-accent);
}

.primary-btn .btn-title {
    color: #FCFAF5;
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-main);
}

.btn-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
}

.btn-subtitle {
    font-size: 13px;
    margin-top: 4px;
    opacity: 0.8;
}

/* その他のあそびかたグリッド */
.sub-mode-container {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 8px;
}

.sub-mode-title {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
}

.sub-mode-grid {
    display: grid;
    grid-template-cols: repeat(3, 1fr);
    gap: 8px;
}

.sub-mode-btn {
    padding: 12px 6px;
    border: 1px solid var(--text-main);
    border-radius: var(--border-radius);
    background-color: transparent;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
}

.sub-mode-btn:active {
    background-color: rgba(46, 43, 38, 0.05);
}

.top-footer {
    text-align: center;
    margin-bottom: 16px;
}

.text-link-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px;
}

.text-link-btn:hover {
    color: var(--text-main);
}

/* ------------------------------------------
   ゲームプレイ画面 ＆ ズーム制御
   ------------------------------------------ */
.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.progress-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.found-counter {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.small-btn {
    padding: 8px 16px;
    border: 1px solid var(--text-main);
    border-radius: var(--border-radius);
    background-color: transparent;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.small-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.game-mode-panels {
    margin-bottom: 12px;
}

.search-panel, .compare-panel, .gentle-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background-color: rgba(46, 43, 38, 0.04);
    border-radius: var(--border-radius);
    font-size: 16px;
}

.panel-label {
    font-weight: 700;
    color: var(--text-muted);
}

.target-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.target-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 18px;
}

.compare-badge, .gentle-badge {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-accent);
}

/* ドットインジケーター */
.progress-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--text-main);
    background-color: transparent;
    transition: background-color 0.3s;
}

.dot.active {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

.difficulty-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.bar-label {
    font-size: 15px;
    color: var(--text-muted);
}

.diff-btn {
    padding: 6px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: transparent;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
}

.diff-btn.active {
    border-color: var(--text-main);
    color: var(--text-main);
    background-color: rgba(46, 43, 38, 0.05);
}

/* ゲーム額装 */
#game-play-area {
    position: relative;
    width: 100%;
}

.game-frame {
    position: relative;
    padding: 12px;
}

.zoom-viewport {
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: #E6E2D8;
    touch-action: none;
    position: relative;
}

.zoom-wrapper {
    transform-origin: 0 0;
    width: 100%;
    will-change: transform;
}

canvas {
    width: 100%;
    height: auto;
    display: block;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

/* ズームボタン */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.zoom-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--text-main);
    border-radius: var(--border-radius);
    background-color: rgba(252, 250, 245, 0.9);
    color: var(--text-main);
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(46,43,38,0.15);
}

.zoom-btn:active {
    background-color: var(--bg-primary);
}

/* おだやかプログレス */
.progress-container {
    width: 100%;
    height: 6px;
    background-color: var(--border-color);
    margin-top: 12px;
    overflow: hidden;
}

#gentle-progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--color-accent);
}

/* アクションバー */
.action-bar {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.compare-switch-btn {
    width: 100%;
    max-width: 280px;
    padding: 16px;
    border: 2px solid var(--color-accent);
    border-radius: var(--border-radius);
    background-color: var(--color-accent);
    color: #FCFAF5;
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-heading);
    cursor: pointer;
    min-height: 54px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.compare-switch-btn:active {
    background-color: #9C392C;
    border-color: #9C392C;
}

/* ------------------------------------------
   わたしの美術館 (図鑑) スタイル
   ------------------------------------------ */
.museum-grid {
    display: grid;
    grid-template-cols: repeat(2, 1fr);
    gap: 16px;
    padding: 12px 0;
    overflow-y: auto;
    max-height: 70vh;
}

.museum-item {
    cursor: pointer;
    transition: transform 0.2s;
}

.museum-item:active {
    transform: scale(0.97);
}

.museum-item .museum-frame {
    padding: 8px;
    border-width: 3px;
    margin-bottom: 8px;
}

.museum-item-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    color: var(--text-main);
    line-height: 1.3;
}

/* 未収蔵シルエット */
.museum-item.locked .hero-mat-image {
    filter: brightness(0) opacity(0.12); /* 墨色のシルエット風 */
}

body.high-contrast .museum-item.locked .hero-mat-image {
    filter: brightness(0) opacity(0.4);
}

.museum-item.locked .museum-item-title {
    color: var(--text-muted);
}

/* ------------------------------------------
   モーダル / キャプションプレート
   ------------------------------------------ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(46, 43, 38, 0.4);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--text-main);
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 92vh;
    overflow-y: auto;
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* 落款 */
.rakkan-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

.rakkan-seal {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--color-accent);
    border: 3px double var(--color-accent);
    padding: 10px 20px;
    letter-spacing: 0.1em;
    transform: rotate(-3deg);
    display: inline-block;
    opacity: 0;
    animation: stampIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: 0.2s;
}

@keyframes stampIn {
    0% {
        opacity: 0;
        transform: scale(1.5) rotate(-15deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(-3deg);
    }
}

/* キャプションプレート */
.caption-plate {
    background-color: #FFF;
    border: 1px solid var(--border-color);
    padding: 20px;
    text-align: left;
}

body.high-contrast .caption-plate {
    background-color: var(--bg-card);
}

.art-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
}

.art-artist {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.art-details {
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

/* 豆知識ボックス */
.trivia-box {
    margin-top: 10px;
    background-color: rgba(181, 73, 58, 0.03);
    border-left: 3px solid var(--color-accent);
    padding: 10px 12px;
}

.trivia-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--color-accent);
    display: block;
    margin-bottom: 4px;
}

.art-trivia {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-main);
}

.result-message {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-accent);
    margin: 0;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-actions {
    display: flex;
    gap: 12px;
}

.share-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--text-main);
    border-radius: var(--border-radius);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
    background-color: transparent;
    color: var(--text-main);
}

.x-btn {
    background-color: var(--text-main);
    color: var(--bg-card);
}

/* あそびかた説明 */
.howto-text {
    font-size: 18px;
    line-height: 2;
    text-align: left;
}

.howto-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#howto-difficulty .difficulty-bar {
    margin-bottom: 0;
}

/* ------------------------------------------
   展覧会図録
   ------------------------------------------ */
.credits-desc {
    font-size: 15px;
    color: var(--text-muted);
    text-align: left;
    margin-bottom: 8px;
}

.credits-list-container {
    display: flex;
    flex-direction: column;
    max-height: 45vh;
    overflow-y: auto;
    padding-right: 8px;
    border-top: 1px solid var(--border-color);
}

.credit-item {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.credit-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.credit-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.credit-item-title {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.credit-item-artist {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.credit-item-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ------------------------------------------
   トースト通知
   ------------------------------------------ */
.game-toast {
    position: fixed;
    left: 50%;
    bottom: 130px;
    transform: translateX(-50%);
    background-color: rgba(46, 43, 38, 0.88);
    color: #F6F2E9;
    padding: 12px 22px;
    border-radius: var(--border-radius);
    font-size: 16px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 60;
}

.game-toast.visible {
    opacity: 1;
}

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

.loading-text {
    font-family: var(--font-heading);
    font-size: 18px;
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
}

/* アニメーション軽減 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-delay: 0s !important;
        animation-duration: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0s !important;
        scroll-behavior: auto !important;
    }
    .rakkan-seal {
        animation: none !important;
        opacity: 1 !important;
        transform: rotate(-3deg) !important;
    }
    .game-toast, #btn-hint {
        transition: none !important;
    }
}

/* 準備中オーバーレイ表示 */
.preparation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-card);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    text-align: center;
    z-index: 25;
    box-sizing: border-box;
}

.preparation-seal {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-muted);
    border: 3px double var(--text-muted);
    padding: 8px 16px;
    margin-bottom: 20px;
    transform: rotate(-2deg);
}

.prep-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.prep-desc {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.8;
}
