/* =================================================================
   はんのうタッチ（kinder-touch）専用スタイル
   すべて #app-kinder-touch でスコープ。ライト/ダーク両対応。
   ================================================================= */

#app-kinder-touch {
    --kt-accent: var(--bs-primary);
    --kt-radius: 1.25rem;
}

#app-kinder-touch .kt-label {
    font-size: 1.05rem;
}

/* ------------- むずかしさ ------------- */
/* 幼児向けにボタンは大きいまま保ちつつ、狭い画面では折り返して横スクロールを防ぐ */
#app-kinder-touch .kt-diff-group {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 8px;
}
#app-kinder-touch .kt-diff-group .btn {
    min-width: 92px;
    border-radius: 999px !important;
    margin: 0 4px;
}
@media (max-width: 575.98px) {
    #app-kinder-touch .kt-diff-group .btn {
        min-width: 84px;
    }
}

/* ------------- モードカード ------------- */
#app-kinder-touch .kt-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.4rem 0.5rem;
    min-height: 180px;
    border: 3px solid var(--bs-border-color);
    border-radius: var(--kt-radius);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    cursor: pointer;
}

#app-kinder-touch .kt-mode-btn:focus-visible {
    border-color: var(--kt-accent);
    transform: translateY(-3px);
    box-shadow: 0 7px 0 rgba(124, 90, 195, 0.25);
    outline: none;
}

@media (hover: hover) { #app-kinder-touch .kt-mode-btn:hover {
    border-color: var(--kt-accent);
    transform: translateY(-3px);
    box-shadow: 0 7px 0 rgba(124, 90, 195, 0.25);
    outline: none;
} }

#app-kinder-touch .kt-mode-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

#app-kinder-touch .kt-mode-emoji {
    font-size: 2.8rem;
    line-height: 1.25;
}

#app-kinder-touch .kt-mode-title {
    font-weight: 800;
    font-size: 1.15rem;
    line-height: 1.15;
}

#app-kinder-touch .kt-mode-sub {
    font-size: 0.82rem;
    color: var(--bs-secondary-color);
}

/* ------------- シールちょう ------------- */
#app-kinder-touch .kt-sticker-book {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-content: flex-start;
    max-width: 420px;
    min-height: 76px;
    padding: 12px;
    border: 2px dashed var(--bs-border-color);
    border-radius: var(--kt-radius);
    background: var(--bs-tertiary-bg);
}

#app-kinder-touch .kt-sticker-book:empty::before {
    content: "あそぶと シールが たまるよ";
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
    align-self: center;
    width: 100%;
    text-align: center;
}

#app-kinder-touch .kt-sticker {
    font-size: 1.9rem;
    line-height: 1;
    animation: kt-pop 0.4s ease;
}

/* ------------- ゲーム画面ヘッダー ------------- */
#app-kinder-touch .kt-game-head .btn {
    min-width: 56px;
    min-height: 56px;
}

#app-kinder-touch .kt-progress-dots {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 240px;
}

#app-kinder-touch .kt-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bs-border-color);
    transition: transform 0.2s ease, background 0.2s ease;
}

#app-kinder-touch .kt-dot.done {
    background: var(--bs-success);
    transform: scale(1.1);
}

/* ------------- 出題文（ターゲット表示） ------------- */
#app-kinder-touch .kt-question {
    font-size: clamp(1.2rem, 4.5vw, 1.7rem);
    min-height: 2.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#app-kinder-touch .kt-q-target {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7em;
    padding: 0.05em 0.2em;
    border-radius: 0.6rem;
    background: var(--bs-tertiary-bg);
    box-shadow: 0 0 0 3px rgba(124, 90, 195, 0.35);
    line-height: 1;
}

/* ------------- もぐらたたき盤 ------------- */
#app-kinder-touch .kt-board {
    --kt-cols: 2;
    display: grid;
    grid-template-columns: repeat(var(--kt-cols), 1fr);
    gap: 12px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 16px;
    border-radius: var(--kt-radius);
    background: var(--bs-tertiary-bg);
}

/* 1マス（穴） */
#app-kinder-touch .kt-hole {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    /* 穴＝地面のくぼみ。暗色でもテーマ変数で見える */
    background:
        radial-gradient(ellipse at 50% 38%, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.05) 60%, transparent 72%),
        var(--bs-secondary-bg);
    border: 3px solid var(--bs-border-color);
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* 出てくる子（ボタン）。ふだんは穴の下に隠れている */
#app-kinder-touch .kt-critter {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.2rem, 11vw, 3.4rem);
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* 下に隠れた状態 */
    transform: translateY(115%) scale(0.7);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.2, 1.3, 0.5, 1), opacity 0.2s ease;
}

/* 出ている状態（ひょっこり） */
#app-kinder-touch .kt-critter.up {
    transform: translateY(0) scale(1);
    opacity: 1;
}

#app-kinder-touch .kt-critter.up:active {
    transform: translateY(0) scale(0.88);
}

/* タッチ成功（ぽん、と弾む） */
#app-kinder-touch .kt-critter.hit {
    animation: kt-hit 0.32s ease;
}

/* ターゲット以外にさわった：やさしく揺れるだけ（赤・×は使わない） */
#app-kinder-touch .kt-critter.wrong {
    animation: kt-wobble 0.48s ease;
}

/* おおきいのタッチ：大小の見分け（up の縮尺を上書き） */
#app-kinder-touch .kt-critter.up.kt-big {
    transform: translateY(0) scale(1.18);
}

#app-kinder-touch .kt-critter.up.kt-small {
    transform: translateY(0) scale(0.62);
}

#app-kinder-touch .kt-critter.up.kt-big:active {
    transform: translateY(0) scale(1.05);
}

#app-kinder-touch .kt-critter.up.kt-small:active {
    transform: translateY(0) scale(0.54);
}

/* ながおしタッチ：おしているあいだ 成長するリング（満ちたら つかまえ） */
#app-kinder-touch .kt-critter {
    position: relative;
}

#app-kinder-touch .kt-hold-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 78%;
    height: 78%;
    transform: translate(-50%, -50%) scale(0.35);
    border-radius: 50%;
    border: 5px solid var(--kt-accent);
    opacity: 0.85;
    pointer-events: none;
    animation-name: kt-hold-grow;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

#app-kinder-touch .kt-critter.holding {
    filter: drop-shadow(0 0 6px rgba(124, 90, 195, 0.5));
}

@keyframes kt-hold-grow {
    0% { transform: translate(-50%, -50%) scale(0.35); opacity: 0.55; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    #app-kinder-touch .kt-hold-ring {
        animation-duration: inherit; /* 進捗を示すため成長は残す */
    }
}

/* ------------- セットクリア ------------- */
#app-kinder-touch .kt-clear-card {
    max-width: 460px;
    padding: 2.2rem 1.5rem;
    border-radius: var(--kt-radius);
    background: var(--bs-tertiary-bg);
    border: 3px solid var(--bs-warning);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

#app-kinder-touch .kt-clear-emoji {
    font-size: 4.5rem;
    line-height: 1.25;
    animation: kt-bounce 0.7s ease;
}

#app-kinder-touch .kt-clear-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--bs-warning);
    margin-top: 0.3rem;
}

#app-kinder-touch .kt-clear-sub {
    font-size: 1.05rem;
    color: var(--bs-secondary-color);
    margin-top: 0.2rem;
}

#app-kinder-touch .kt-clear-sticker {
    font-size: 3.4rem;
    margin-top: 0.6rem;
    animation: kt-pop 0.5s ease 0.2s both;
}

/* ------------- アニメーション ------------- */
@keyframes kt-pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

@keyframes kt-hit {
    0% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-10px) scale(1.18); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes kt-bounce {
    0% { transform: translateY(0) scale(0.6); }
    40% { transform: translateY(-18px) scale(1.1); }
    70% { transform: translateY(0) scale(0.95); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes kt-wobble {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-6px) rotate(-4deg); }
    40% { transform: translateX(6px) rotate(4deg); }
    60% { transform: translateX(-4px) rotate(-2deg); }
    80% { transform: translateX(4px) rotate(2deg); }
}

/* アニメーション減 設定を尊重（出入りは残しつつ過度な動きを抑える） */
@media (prefers-reduced-motion: reduce) {
    #app-kinder-touch .kt-clear-emoji,
    #app-kinder-touch .kt-sticker,
    #app-kinder-touch .kt-clear-sticker {
        animation-duration: 0.01ms !important;
    }
}

/* ============================================================
 * スマホ: あそびを えらぶ画面を1画面に収める
 * ------------------------------------------------------------
 * 子どもは選択肢を探してスクロールしない。「むずかしさ」と
 * 5つのあそびカードが同時に見えている状態を作る。
 * カードは幅いっぱいなので、高さを詰めてもタップしやすさは落ちない。
 * ============================================================ */
@media (max-width: 767.98px) {
    #app-kinder-touch .kt-mode-btn {
        min-height: 108px;
        padding: 0.6rem 0.4rem;
        gap: 0.1rem;
        border-width: 2px;
    }

    #app-kinder-touch .kt-mode-emoji {
        font-size: 1.9rem;
    }

    #app-kinder-touch .kt-mode-title {
        font-size: 0.98rem;
    }

    /* 何をするあそびかの一言。小さくしても残す（これがあると迷わない） */
    #app-kinder-touch .kt-mode-sub {
        font-size: 0.7rem;
        line-height: 1.2;
    }

    /* むずかしさは1行に収める */
    #app-kinder-touch .kt-diff-group .btn {
        min-width: 76px;
        padding: 0.4rem 0.5rem !important;
        font-size: 0.95rem !important;
    }

    #app-kinder-touch .kt-label {
        margin-bottom: 0.35rem !important;
    }

    /* シールちょう（ごほうび表示。操作ではないので控えめに） */
    #app-kinder-touch .kt-sticker-book {
        min-height: 56px;
        padding: 8px;
    }
}

/* ============================================================
 * スマホ: あそんでいる間は「盤面」を画面いっぱいに使う
 * ------------------------------------------------------------
 * もぐらたたきは穴が全部見えていないと成立しない。あそび中は
 * タイトルと説明を隠し、操作ヘッダーも1行に畳んで、盤面に高さを譲る。
 * :has() は iOS 15.4+ / Chrome 105+ で利用可能。
 * ============================================================ */
@media (max-width: 767.98px) {

    /* あそび中・クリア表示中はタイトルを隠す（メニューに戻れば再び出る） */
    body.genre-kinder main:has(#kt-game:not(.d-none)) > section:first-of-type,
    body.genre-kinder main:has(#kt-clear:not(.d-none)) > section:first-of-type {
        display: none;
    }

    /* 操作ヘッダーは1行に収める（もどる／しんちょく／音） */
    #app-kinder-touch .kt-game-head {
        flex-wrap: nowrap !important;
        margin-bottom: .5rem !important;
    }

    #app-kinder-touch .kt-game-head .btn {
        min-width: 46px;
        min-height: 46px;
        padding: .35rem .5rem !important;
    }

    #app-kinder-touch .kt-progress-dots {
        max-width: 150px;
        gap: 4px;
    }

    #app-kinder-touch .kt-dot {
        width: 11px;
        height: 11px;
    }

    /* 出題文は1行ぶんに */
    #app-kinder-touch .kt-question {
        min-height: 1.6em;
        margin-bottom: .5rem !important;
    }

    /* 盤面は余白を詰めて、穴をできるだけ大きく保つ */
    #app-kinder-touch .kt-board {
        gap: 8px;
        padding: 8px;
    }
}

