/* 算数版の共通変数を使用することを想定 */
:root {
    --word-bg: #fdfbf7;
    --accent-word: #ff9800;
    /* 国語はオレンジ系のアクセント */
}

#game-container {
    max-width: 571px;
    margin: auto;
    width: 98%;
    font-family: 'Hiragino Kaku Gothic ProN', sans-serif;
    background: var(--japanese-bg);
    padding: 10px 80px;
}

#answer {
    font-size: 40px;
    font-weight: bold;
    color: var(--accent-main);
    letter-spacing: 0.1em;
}



/* 文字ボタン：算数のキーパッド（.key）をベースに丸みを追加 */
.letter-btn {
    background: var(--bg-card);
    border: 3px solid var(--accent-main);
    border-radius: 18px;
    font-size: 28px;
    font-weight: bold;
    width: 60px;
    height: 60px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 0 var(--border-soft);
    transition: 0.1s;
    color: var(--text-main);
}

.letter-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--border-soft);
}

/* 使用済みボタン：算数にない要素だが、馴染むように調整 */
.letter-btn.is-used {
    opacity: 0.15;
    pointer-events: none;
    transform: scale(0.9);
}

/* 制御ボタンエリア */
.control-area {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.sub-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-soft);
    border-radius: 12px;
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-main);
}

/* 正解時のアニメーション（算数の演出を参考） */
.correct-animation {
    animation: success-pulse 0.5s ease-out;
    color: #4caf50 !important;
}

@keyframes success-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* スタートボタンを可愛く */
.main-btn {
    padding: 15px 40px;
    font-size: 1.5rem;
    background: #ff9800;
    /* オレンジ */
    color: white;
    border: none;
    border-radius: 50px;
    box-shadow: 0 6px 0 #e68a00;
    cursor: pointer;
    transition: 0.1s;
    font-weight: bold;
    margin: 180px auto;
    display: block;
}

.main-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #e68a00;
}

/* ★解答欄のガタつき防止 */
#answer-wrapper {
    /* 2段分を想定した高さを確保 (約120px) */
    min-height: 120px;
    display: flex;
    flex-direction: column;
    /* ヒントと回答を縦に並べる */
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    border-radius: 15px;
    border: 2px dashed #ffb74d;
    position: relative;
    padding: 10px;
    box-sizing: border-box;
    background: var(--bg-card);
    color: var(--text-main);
}

.answer-box {
    font-size: 32px;
    /* 少しサイズを調整して2段に入りやすくする */
    margin: 5px auto;
    min-height: 85px;
    /* 文字が入っていなくても高さを維持 */
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    /* 文字が溢れたら折り返す */
    justify-content: center;
    align-items: center;
    letter-spacing: 5px;
    line-height: 1.2;
    /* 2段になった時の行間 */
    font-weight: bold;
    transition: color 0.2s;
    border-bottom: none;
    /* 枠線は親要素にあるので不要 */


}

/* --- 文字ボタンコンテナの改善 --- */
#letters-container {
    /* ボタンが3段になっても耐えられる高さを確保 (約180px) */
    min-height: 180px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    /* 上詰めで配置 */
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    /* 枠を意識させるなら微かに色を */
    border-radius: 10px;
}

/* 文字ボタン自体のサイズを微調整 */
.letter-btn {
    width: 54px;
    height: 54px;
    font-size: 24px;
}

/* --- スマホ・小画面対応 --- */
@media (max-width: 400px) {
    .answer-box {
        font-size: 26px;
    }

    .letter-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .hint {
        position: absolute;
        top: 0;
        font-size: 14px;
        color: #ff5722;
        font-weight: bold;
        left: 5px;

    }
}

#answer {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 5px;
    min-width: 1em;
    /* 空でも少し幅を持つように */
}

/* ★ボタンコンテナの高さ固定 */
#letters-container {
    min-height: 60px;
    /* ボタンが並ぶエリアの高さも固定 */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.letter-btn-wrapper {
    display: inline-block;
    position: relative;
    margin: 5px;
}

.key-guide {
    position: absolute;
    top: -10px;
    right: -5px;
    background: #333;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    pointer-events: none;
    /* ガイド自体はクリック不可 */
}

/* 回答エリアの固定と枠線 */
.answer-box {
    font-size: 40px;
    margin: 20px auto;
    min-height: 65px;
    max-width: 90%;
    border-bottom: 4px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    letter-spacing: 5px;
    font-weight: bold;
    transition: color 0.2s;
}

/* --- 演出用スタイル（メディアクエリの外に出す） --- */

/* 正解時のフラッシュ */
.correct-flash {
    background-color: #4caf50 !important;
    color: white !important;
    transform: scale(1.1);
    transition: 0.2s;
}

/* 不正解時の震えと赤背景 */
.error-flash {
    background-color: #f44336 !important;
    color: white !important;
    animation: shake 0.1s linear infinite;
}

/* 震えるアニメーション定義 */
@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* 地図の正解色（SVG用） */
.is-correct path,
.is-correct polygon,
.is-correct g {
    fill: #4caf50 !important;
    transition: fill 0.5s;
}

/* 警告ボタン */
.sub-btn.warning {
    background-color: #9e9e9e;
    color: white;
}

/* キーボードガイドの装飾 */
.letter-btn-wrapper {
    display: inline-block;
    position: relative;
    margin: 5px;
}

.key-guide {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #333;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

/* 使用済みボタンの半透明化 */
.is-used {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

#game {
    text-align: center;
    max-width: 600px;
    margin: auto;
}

#letters button {

    font-size: 32px;
    margin: 10px;
    padding: 20px;
    cursor: pointer;

}

#answer {

    font-size: 40px;
    margin: 20px;
    min-height: 55px;

}

#timer {
    font-size: 28px;
}

#score {
    font-size: 28px;
}