@charset "UTF-8";

/* =========================================
   1. 変数定義 & 基本設定
   ========================================= */
:root {
    /* 温かみのあるテーマカラー */
    --primary-color: #f0a96e;
    /* 優しいテラコッタオレンジ */
    --secondary-color: #ffd54f;
    /* はちみつイエロー */
    --accent-color: #8d6e63;
    /* 温かいブラウン */
    --background-color: #fdf8e1;
    /* クリーム色の紙のような背景 */
    --container-bg-color: #fffef7;
    /* 少し明るいクリーム */
    --text-color: #5d4037;
    /* ダークブラウン */
    --white-color: #fff;

    /* デザインパーツ */
    --border-radius-large: 20px;
    --border-radius-medium: 12px;
    --box-shadow-soft: 0 8px 30px rgba(141, 110, 99, 0.15);
    --key-shadow: 0 3px 5px rgba(141, 110, 99, 0.2);
}

/* ★重要: 全要素の幅計算を統一（レイアウト崩れ防止） */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Kosugi Maru', 'Yomogi', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.8;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
    overflow-x: hidden;
}

/* =========================================
   2. ヘッダー・メイン・フッター
   ========================================= */
.header {
    background-color: var(--accent-color);
    color: var(--white-color);
    padding: 15px 20px;
    text-align: center;
    box-shadow: var(--box-shadow-soft);
    border-bottom: 5px solid #795548;
}

.header h1 {
    margin: 0;
    font-family: 'Yomogi', cursive;
    font-size: 2.2em;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 20px;
}

.footer {
    padding: 30px;
    text-align: center;
}

/* =========================================
   3. レッスンコンテナ & 共通UI
   ========================================= */
.lesson-container {
    background: var(--container-bg-color);
    padding: 40px;
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-soft);
    width: 100%;
    /* PCで見やすい幅に設定 */
    max-width: 960px;
    text-align: center;
    border: 2px solid var(--accent-color);
    animation: fadeIn 1s ease-in-out;
}

/* 画面を広く使う場合のクラス */
.lesson-container.w-full {
    max-width: 95% !important;
    transition: max-width 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.instruction {
    font-size: 1.3em;
    color: var(--text-color);
    margin-bottom: 25px;
}

.lesson-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.lesson-header h2 {
    margin: 0;
    color: var(--accent-color);
    font-size: 1.8em;
    font-family: 'Yomogi', cursive;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.step-badge {
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 8px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.2em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    font-family: 'Yomogi', cursive;
}

/* 読み上げボタン */
.speak-button {
    background-color: var(--container-bg-color);
    border: 2px solid var(--primary-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--key-shadow);
}

.speak-button:hover {
    background-color: #fff3e0;
    transform: scale(1.1);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.speak-button svg {
    color: var(--primary-color);
    width: 28px;
    height: 28px;
}

/* リセットボタン */
.reset-button {
    margin-top: 30px;
    background: #c5a59a;
    color: var(--white-color);
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-family: 'Yomogi', cursive;
    cursor: pointer;
    transition: background-color 0.2s;
}

.reset-button:hover {
    background: var(--accent-color);
}

/* メッセージ・通知 */
.message {
    margin-top: 30px;
    padding: 20px;
    border-radius: var(--border-radius-medium);
    background-color: #fffde7;
    font-weight: bold;
    min-height: 28px;
    transition: all 0.3s ease;
    font-size: 1.3em;
    color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.success {
    background-color: #dcedc8;
    color: #558b2f;
    border: 2px solid #aed581;
}

.feedback-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
}

.feedback-correct {
    background-color: #dcedc8;
    color: #558b2f;
    border: 1px solid #aed581;
}

.feedback-incorrect {
    background-color: #ffcdd2;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* =========================================
   4. 各種アクションボタン
   ========================================= */
.next-button {
    background: var(--accent-color);
    color: var(--white-color);
    border: none;
    padding: 18px 45px;
    border-radius: 35px;
    font-size: 1.4em;
    font-family: 'Yomogi', cursive;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 0 #5d4037, 0 8px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.next-button:hover:not(:disabled) {
    background: #a1887f;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 0 #5d4037, 0 10px 20px rgba(0, 0, 0, 0.3);
}

.next-button:disabled {
    background: #bdbdbd;
    box-shadow: 0 4px 0 #9e9e9e, 0 6px 10px rgba(0, 0, 0, 0.1);
    cursor: not-allowed;
    transform: none;
}

.run-button {
    background: var(--accent-color);
    color: var(--white-color);
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.3em;
    font-family: 'Yomogi', cursive;
    cursor: pointer;
    box-shadow: 0 6px 0 #5d4037, 0 8px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    align-self: center;
}

.run-button:hover {
    background: #a1887f;
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #5d4037, 0 10px 20px rgba(0, 0, 0, 0.3);
}

.check-button {
    background: var(--accent-color);
    color: var(--white-color);
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 1.2em;
    font-family: 'Yomogi', cursive;
    cursor: pointer;
    box-shadow: 0 4px 0 #5d4037, 0 6px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.check-button:hover {
    background: #a1887f;
    transform: translateY(-1px);
}

/* =========================================
   5. タイピング・キーボード
   ========================================= */
.keyboard {
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background-color: #ece5d8;
    border-radius: var(--border-radius-medium);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
    max-width: 100%;
}

.key-row {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 10px;
}

.key {
    border: none;
    background-color: var(--container-bg-color);
    border-radius: 10px;
    width: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 5px;
    font-weight: bold;
    color: var(--text-color);
    transition: all 0.1s ease;
    user-select: none;
    box-shadow: var(--key-shadow);
    flex-shrink: 1;
    line-height: 1.2;
}

.main-key {
    font-size: 1.4em;
    font-weight: bold;
    color: var(--text-color);
}

.sub-key {
    font-size: 0.9em;
    color: #a99a95;
}

.key.hidden {
    visibility: hidden;
    flex-shrink: 1;
}

.home-key,
.target-key {
    background-color: var(--primary-color);
    color: var(--white-color);
    box-shadow: 0 3px 0 #d88a51, var(--key-shadow);
}

.home-key .main-key,
.home-key .sub-key,
.target-key .main-key,
.target-key .sub-key {
    color: var(--white-color);
}

.bump::after {
    content: '';
    display: block;
    width: 12px;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.7);
    position: absolute;
    bottom: 10px;
    border-radius: 2px;
}

.key.active {
    transform: translateY(2px) scale(0.95);
    background-color: var(--secondary-color);
    color: var(--text-color);
    box-shadow: 0 1px 0 #e8b939, 0 2px 3px rgba(0, 0, 0, 0.2);
}

.finger-guide {
    margin: 25px 0;
    background-color: #f5eee0;
    padding: 20px;
    border-radius: var(--border-radius-medium);
    font-size: 1.2em;
    color: var(--accent-color);
    border: 2px dashed var(--primary-color);
}

.finger-guide strong {
    color: var(--primary-color);
}

.word-display-wrapper {
    background-color: #ece5d8;
    padding: 20px;
    border-radius: var(--border-radius-medium);
    margin: 30px auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.word-display {
    font-family: 'Yomogi', cursive;
    font-size: 3em;
    font-weight: bold;
    color: var(--accent-color);
    padding: 20px;
    background-color: var(--container-bg-color);
    border-radius: var(--border-radius-medium);
    min-height: 60px;
    letter-spacing: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: pre-wrap;
}

.word-display.error {
    animation: shake 0.5s;
}

.word-display .completed {
    color: #bcaaa4;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* =========================================
   6. Blockly & コード入力スタイル
   ========================================= */
.blockly-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.blockly-wrapper {
    height: 400px;
    width: 100%;
    border-radius: var(--border-radius-medium);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
    background-color: #ece5d8;
}

.output-area {
    background-color: #fffde7;
    border-radius: var(--border-radius-medium);
    min-height: 100px;
    padding: 20px;
    font-size: 1.2em;
    color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.code-input-area {
    margin: 30px 0;
    padding: 20px;
    background-color: #f5eee0;
    border-radius: var(--border-radius-medium);
    border: 2px solid var(--accent-color);
}

.code-input-label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.1em;
    text-align: left;
}

.code-input-wrapper {
    position: relative;
    margin: 10px 0;
    text-align: left;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.code-highlights {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 15px;
    border: 2px solid transparent;
    font-family: Consolas, Monaco, monospace;
    font-size: 16px;
    line-height: 1.5;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
    overflow: hidden;
    background-color: #2d2d2d;
    border-radius: 8px;
}

.code-textarea {
    position: relative !important;
    z-index: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 250px;
    padding: 15px;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    font-family: Consolas, Monaco, monospace;
    font-size: 16px;
    line-height: 1.5;
    background: transparent !important;
    color: #fff !important;
    resize: vertical;
}

.zenkaku-highlight {
    background-color: rgba(255, 69, 58, 0.4);
    border: 1px solid #ff453a;
    border-radius: 2px;
    color: #ff453a !important;
    font-weight: bold;
}

.copy-button-container {
    text-align: right;
    margin-top: 5px;
}

.copy-btn {
    background: var(--secondary-color);
    border: 2px solid var(--accent-color);
    padding: 4px 12px;
    border-radius: 15px;
    font-family: 'Yomogi', cursive;
    font-size: 0.85em;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--accent-color);
    margin-bottom: 10px;
}

/* =========================================
   7. ステージリスト (Flexbox: 確実に並べる)
   ========================================= */

/* (A) 古い形式のステップグリッド (display: flexに統一) */
.step-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    /* 中央寄せ */
    gap: 20px;
    margin-top: 30px;
}

.step-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius-medium);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.step-number {
    font-family: 'Yomogi', cursive;
    font-size: 2em;
    color: var(--white-color);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.step-item.completed {
    background-color: var(--primary-color);
    box-shadow: 0 4px 0 #d88a51, var(--key-shadow);
}

.step-item.completed::after {
    content: '✔';
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 1.2em;
    color: var(--white-color);
    opacity: 0.8;
}

.step-item.next-step {
    background-color: var(--accent-color);
    box-shadow: 0 4px 0 #5d4037, var(--key-shadow);
    animation: pulse 1.5s infinite;
}

.step-item.locked {
    background-color: #d7ccc8;
    box-shadow: 0 4px 0 #bcaaa4;
    cursor: not-allowed;
    pointer-events: none;
}

.step-item.locked .step-number {
    color: #bcaaa4;
}

.step-item.locked::before {
    content: '🔒';
    position: absolute;
    font-size: 2em;
    opacity: 0.6;
}

/* (B) 新しいクエストリスト (Flexbox強制レイアウト) */
.quest-list {
    list-style: none;
    padding: 0;

    /* ▼▼▼ Flexbox設定 ▼▼▼ */
    display: flex;
    flex-wrap: wrap;
    /* 折り返し */
    gap: 20px;
    /* 隙間 */
    width: 100%;
    /* 全幅 */

    margin-top: 20px;
    margin-bottom: 40px;
}

/* ▼▼▼ ここが最重要：アイテムの幅設定 ▼▼▼ */
.quest-list>li {
    display: block;
    /* flex-grow: 1;  (余白があれば伸びる)
      flex-shrink: 0; (基本サイズより縮まない)
      flex-basis: 240px; (基準の幅)
    */
    flex: 1 0 240px;

    /* 最大幅を親に合わせる */
    max-width: 100%;
}

/* カード本体 */
.quest-item {
    width: 100%;
    /* liの中で広げる */
    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 3px solid var(--accent-color);
    border-radius: 15px;
    padding: 15px 20px;
    text-decoration: none;
    color: var(--text-color);
    position: relative;
    overflow: hidden;
    min-height: 80px;
    height: 100%;
    box-shadow: 4px 4px 0 rgba(141, 110, 99, 0.2);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

a.quest-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 6px 8px 0 rgba(141, 110, 99, 0.3);
    background-color: #fff8e1;
    border-color: var(--primary-color);
}

.quest-item h4 {
    margin: 0;
    /* font-size: 1.3em; */
    /* font-family: 'Yomogi', cursive; */
    /* font-weight: bold; */
    color: var(--text-color);
    z-index: 2;
    flex: 1;
    padding-right: 10px;
    word-break: break-all;
}

.quest-item h4::before {
    content: '📌';
    margin-right: 8px;
    font-size: 0.9em;
}

h3.category-title {
    font-size: 1.3em;
    color: var(--text-color);
    margin-top: 30px;
    margin-bottom: 15px;
    font-family: 'Yomogi', cursive;
    border-bottom: 3px dashed var(--accent-color);
    padding-bottom: 5px;
    display: inline-block;
}

h3.category-title a {
    text-decoration: none;
    color: var(--accent-color);
}

/* クリア済み */
.quest-item.completed {
    background-color: #f1f8e9;
    border-color: #8bc34a;
}

.quest-item.completed h4 {
    color: #33691e;
}

.quest-item.completed h4::before {
    content: '✅';
}

/* ロック中 */
.quest-item.locked {
    background-color: #eceff1;
    border-color: #cfd8dc;
    border-style: dashed;
    color: #90a4ae;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.8;
}

.quest-item.locked h4 {
    color: #90a4ae;
}

.quest-item.locked h4::before {
    content: '🔒';
    opacity: 0.5;
}

/* バッジ */
.quest-item .status-badge {
    font-family: 'Kosugi Maru', sans-serif;
    font-size: 0.85em;
    font-weight: bold;
    padding: 5px 12px;
    border-radius: 20px;
    white-space: nowrap;
    z-index: 2;
    letter-spacing: 1px;
}

a.quest-item:not(.completed) .status-badge {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 0 #bf360c;
}

.quest-item.completed .status-badge {
    background: #8bc34a;
    color: #fff;
    box-shadow: 0 2px 0 #558b2f;
    transform: rotate(-10deg);
}

.quest-item.locked .status-badge {
    display: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* =========================================
   8. その他 (お道具箱・外部リンクなど)
   ========================================= */
.floating-toolbar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 9999;
}

.float-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background-color: #fff;
    border: 3px solid var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 0;
    font-family: 'Yomogi', cursive;
}

.float-btn:hover {
    transform: scale(1.1) translateY(-5px);
    background-color: var(--secondary-color);
}

.btn-icon {
    font-size: 1.8em;
    line-height: 1.2;
    margin-top: 2px;
}

.btn-label {
    font-size: 0.75em;
    font-weight: bold;
    line-height: 1.2;
}

/* ゲームリンク等 */
.celebration-text {
    font-size: 1.5em;
    font-family: 'Yomogi', cursive;
    color: var(--primary-color);
    margin-bottom: 30px;
}

.game-links-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
}

.game-link-button {
    display: inline-block;
    background: var(--secondary-color);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: var(--border-radius-medium);
    text-decoration: none;
    font-family: 'Yomogi', cursive;
    font-size: 1.3em;
    box-shadow: var(--key-shadow);
    transition: all 0.2s ease;
}

.game-link-button:hover {
    transform: scale(1.05);
    background: #ffca28;
}

.game-link-button::before {
    content: '🎮';
    margin-right: 10px;
}

.icon-eye::before {
    content: '👀';
    font-size: 1.5em;
}

.icon-code::before {
    content: '📜';
    font-size: 1.5em;
}

.icon-puzzle::before {
    content: '🧩';
    font-size: 1.5em;
}

/* =========================================
   9. スマホレスポンシブ
   ========================================= */
@media (max-width: 600px) {
    .lesson-container {
        padding: 20px;
    }

    .lesson-header h2 {
        font-size: 1.4em;
    }

    .key-row {
        margin-bottom: 1.5vw;
    }

    .key {
        width: 8vw;
        height: 8vw;
        min-width: 28px;
        min-height: 28px;
        font-size: 1em;
        margin: 0 0.8vw;
        border-radius: 1.5vw;
        line-height: 1.1;
    }

    .main-key {
        font-size: 1.2em;
    }

    .sub-key {
        font-size: 0.8em;
    }

    .bump::after {
        width: 2vw;
        height: 0.5vw;
        bottom: 1.5vw;
    }

    .next-button {
        padding: 15px 30px;
        width: 90%;
        font-size: 1.1em;
        border-radius: 25px;
    }

    .header h1 {
        font-size: 1.6em;
    }

    .step-badge {
        font-size: 1.0em;
        padding: 6px 15px;
    }

    .instruction {
        font-size: 1.0em;
    }

    .finger-guide,
    .message {
        font-size: 1.0em;
        padding: 15px;
    }

    .speak-button svg {
        width: 20px;
        height: 20px;
    }

    .word-display {
        font-size: 1.5em;
        min-height: 40px;
    }

    .blockly-wrapper {
        height: 300px;
    }

    .output-area {
        height: 80px;
    }

    .floating-toolbar {
        bottom: 10px;
        right: 10px;
        gap: 10px;
    }

    .float-btn {
        width: 55px;
        height: 55px;
    }

    .btn-icon {
        font-size: 1.4em;
    }

    .btn-label {
        font-size: 0.6em;
    }

    /* スマホで縦並びにするのはここだけ */
    .quest-list {
        flex-direction: column;
        /* 縦並び */
    }

    .quest-list>li {
        width: 100%;
        flex: 1 1 auto;
    }

    .quest-item {
        min-height: 60px;
        padding: 12px 15px;
    }

    /* .quest-item h4 {
        font-size: 1.1em;
    } */
}