/* ==========================================================================
   漢字ゲシュタルト間違い探し - スタイル設計（ポータル統一暖色パレット）
   ========================================================================== */

/* 他のゲームと共通するデザインシステム変数 */
:root {
    --bg-color: #FDFBF7; /* 塗り絵・間違い探し共通の優しいベージュ */
    --panel-bg: #ffffff;
    --panel-border: #E97C5D; /* メインテーマオレンジ */
    --panel-border-light: rgba(233, 124, 93, 0.15);
    --text-main: #333333;
    --text-sub: #555555;
    --primary-color: #E8834A;
    --primary-gradient: linear-gradient(135deg, #E8834A 0%, #E97C5D 100%);
    --accent-red: #E04444; /* 警告用赤 */
    --accent-green: #5B9E6E; /* 正解用緑 */
    --shadow-soft: 0 6px 20px rgba(142, 131, 114, 0.12);
    --font-kanji: 'Noto Sans JP', 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', 'Meiryo', sans-serif;
}

/* 全体設定 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', 'Meiryo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-top: 76px; /* 52px固定ナビ + 24px余白 */
}

/* グローバルナビ（他ゲームと共通） */
.g-nav {
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: #E8834A; display: flex; align-items: center;
    padding: 0 16px; z-index: 100; gap: 10px;
}
.g-nav-arrow { color: white; font-size: 1.5rem; text-decoration: none; line-height: 1; }
.g-nav-title { color: white; font-size: 1rem; font-weight: bold; text-decoration: none;
    font-family: 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', 'Meiryo', sans-serif; }

.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ポータル統一パネルスタイル */
.glass-panel {
    background: var(--panel-bg);
    border: 3.5px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
}

/* ヘッダーエリア */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 25px;
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.game-header .main-title {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: none;
    text-align: center;
}

/* ボタン関連 */
.back-btn, .sub-btn, .primary-btn {
    font-family: inherit;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
}

.sub-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.primary-btn {
    background: var(--primary-gradient);
    color: #ffffff;
    padding: 14px 28px;
    border-radius: 14px;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(233, 124, 93, 0.25);
}

.primary-btn:hover {
    transform: scale(1.04);
    background: #d36445;
    box-shadow: 0 6px 16px rgba(233, 124, 93, 0.35);
}

/* ゲームのレイアウト設計 */
.game-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

/* サイドパネル */
.side-panel {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.panel-section {
    border-bottom: 1px solid var(--panel-border-light);
    padding-bottom: 20px;
}

.panel-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.section-title {
    font-size: 16px;
    color: var(--text-sub);
    margin-bottom: 12px;
    font-weight: 700;
}

/* 難易度切り替えボタン */
.difficulty-selectors {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.diff-btn {
    background: rgba(233, 124, 93, 0.03);
    border: 1.5px solid var(--panel-border-light);
    padding: 12px 15px;
    border-radius: 12px;
    color: var(--text-sub);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.diff-btn .diff-level {
    font-size: 16px;
    font-weight: 700;
}

.diff-btn .diff-desc {
    font-size: 12px;
    opacity: 0.8;
}

.diff-btn:hover {
    background: rgba(233, 124, 93, 0.08);
    color: var(--text-main);
}

.diff-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(233, 124, 93, 0.2);
}

/* ステータスセクション */
.stats-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 15px;
    color: var(--text-sub);
    font-weight: 700;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
}

#combo-val {
    color: var(--accent-green);
    text-shadow: none;
}

.guide-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-sub);
}

/* ゲーム盤面エリア */
.board-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* タイマーバー */
.timer-container {
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.timer-bar-wrapper {
    flex: 1;
    height: 14px;
    background: #eae6df;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.timer-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green) 0%, #ffb86c 60%, var(--accent-red) 100%);
    border-radius: 7px;
    transition: width 0.1s linear;
}

.timer-text {
    font-size: 18px;
    font-weight: 800;
    min-width: 50px;
    text-align: right;
    color: var(--text-main);
}

/* 漢字グリッド */
.grid-outer-container {
    position: relative;
    flex: 1;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

.kanji-grid {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: 550px;
    aspect-ratio: 1/1;
    margin: 0 auto;
}

/* 難易度別のグリッド構成 */
.kanji-grid.easy {
    grid-template-columns: repeat(6, 1fr);
}
.kanji-grid.medium {
    grid-template-columns: repeat(9, 1fr);
}
.kanji-grid.hard {
    grid-template-columns: repeat(12, 1fr);
}

/* 各グリッドセル（クッキリ読みやすい白背景と太文字） */
.grid-cell {
    background: #fdfcf7;
    border: 2px solid #eae6df;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-kanji);
    font-weight: 900;
    color: #222222;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    transition: all 0.1s ease;
}

/* フォントサイズの自動適合（大きくハッキリ） */
.kanji-grid.easy .grid-cell { font-size: 48px; }
.kanji-grid.medium .grid-cell { font-size: 34px; border-radius: 10px; }
.kanji-grid.hard .grid-cell { font-size: 26px; border-radius: 8px; }

.grid-cell:hover {
    background: #ffffff;
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(233,124,93,0.15);
}

/* エフェクト：正解時に緑色に光る */
.grid-cell.correct-effect {
    background: #eef7f0 !important;
    border-color: var(--accent-green) !important;
    color: var(--accent-green) !important;
    animation: pulse-correct 0.3s ease-out;
}

@keyframes pulse-correct {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ペナルティ：誤クリック時の画面赤フラッシュ */
.flash-error {
    animation: red-flash 0.35s ease-out;
}

@keyframes red-flash {
    0% { background-color: rgba(224, 68, 68, 0.15); }
    100% { background-color: transparent; }
}

/* オーバーレイ（スタート画面） */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(253, 251, 247, 0.96);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
    border-radius: 20px;
}

.overlay-content {
    max-width: 450px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.overlay-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-color);
}

.overlay-desc {
    font-size: 16px;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 10px;
}

/* 結果表示モーダル（ポータル統一調） */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    width: 100%;
    max-width: 480px;
    padding: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.modal-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-color);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fdfbf7;
    padding: 20px;
    border-radius: 16px;
    border: 2px dashed rgba(233, 124, 93, 0.3);
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-row.sub-row {
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-top: 12px;
}

.result-label {
    font-size: 16px;
    color: var(--text-sub);
    font-weight: 700;
}

.result-value {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary-color);
}

.result-value-sub {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.new-record-badge {
    background: var(--accent-green);
    color: #ffffff;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 14px;
    display: inline-block;
    align-self: center;
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-6px); }
}

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

.modal-actions .primary-btn, .modal-actions .sub-btn {
    width: 100%;
}
.modal-actions .sub-btn {
    background: #eae6df;
    color: var(--text-main);
    border: none;
}
.modal-actions .sub-btn:hover {
    background: #d8d4cd;
}
