/* ============================================================
   ずけいであそぼう！
   style.css
   ============================================================ */


/* ============================================================
   基本設定
   ============================================================ */

* {
    box-sizing: border-box;
}


html {
    margin: 0;
    padding: 0;

    scroll-behavior: smooth;
}


body {
    margin: 0;
    padding: 0;

    min-height: 100vh;

    background:
        linear-gradient(
            180deg,
            #fffaf2 0%,
            #f7fbff 100%
        );

    color: #333;

    font-family:
        "Hiragino Kaku Gothic ProN",
        "Hiragino Sans",
        "Yu Gothic",
        "YuGothic",
        "Noto Sans JP",
        sans-serif;

    -webkit-font-smoothing: antialiased;

    -webkit-tap-highlight-color: transparent;
}


button {
    font-family: inherit;
}


.hidden {
    display: none !important;
}


/* ============================================================
   アプリ
   ============================================================ */

#app {
    min-height: 100vh;

    display: flex;
    flex-direction: column;
}


.screen {
    width: 100%;
}


/* ============================================================
   ヘッダー
   ============================================================ */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    /* background: rgba(255, 255, 255, 0.96); ← コメントアウトまたは透明に */
    background: transparent;
    /* border-bottomやbox-shadowも不要であれば削除 */
}


.header-inner {
    width: min(1100px, 94%);

    min-height: 76px;

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        150px
        1fr
        150px;

    align-items: center;

    gap: 10px;
}


.home-button {
    justify-self: start;

    min-width: 110px;

    padding: 12px 20px;

    border: 3px solid #e6d7c5;

    border-radius: 18px;

    background: #fff;

    color: #555;

    font-size: 20px;

    font-weight: 800;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        background 0.15s ease;
}


.home-button:hover {
    background: #fff8ed;
}


.home-button:active {
    transform: scale(0.94);
}


.header-title {
    margin: 0;

    text-align: center;

    font-size: clamp(24px, 4vw, 34px);

    font-weight: 800;

    color: #444;

    letter-spacing: 0.04em;
}


.header-spacer {
    width: 100%;
}


/* ============================================================
   メイン
   ============================================================ */

.main-content {
    width: 100%;

    flex: 1;

    padding: 30px 16px 50px;
}


/* ============================================================
   ホーム
   ============================================================ */

.home-container {
    width: min(1000px, 100%);

    margin: 0 auto;
}


.home-title-area {
    text-align: center;

    margin-bottom: 36px;
}


.home-title-icon {
    margin-bottom: 8px;

    font-size: clamp(32px, 6vw, 52px);

    letter-spacing: 0.15em;

    color: #777;
}


.home-title {
    margin: 0;

    font-size: clamp(34px, 7vw, 58px);

    font-weight: 800;

    letter-spacing: 0.05em;

    color: #444;
}


.home-subtitle {
    margin: 12px 0 0;

    font-size: clamp(18px, 3vw, 24px);

    font-weight: 700;

    color: #777;
}


/* ============================================================
   ゲームメニュー
   ============================================================ */

.game-menu {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 18px;
}


.game-menu-button {
    position: relative;

    min-height: 150px;

    padding:
        24px
        22px
        20px
        78px;

    border: 4px solid #eadfd2;

    border-radius: 28px;

    background: #fff;

    color: #444;

    box-shadow:
        0 5px 0 #e5d8c9,
        0 8px 18px rgba(0, 0, 0, 0.07);

    cursor: pointer;

    text-align: left;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}


.game-menu-button:hover {
    background: #fffdf9;

    transform: translateY(-2px);
}


.game-menu-button:active {
    transform: translateY(4px);

    box-shadow:
        0 2px 0 #e5d8c9;
}


.game-number {
    position: absolute;

    left: 18px;
    top: 50%;

    transform: translateY(-50%);

    width: 48px;
    height: 48px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #f3eee8;

    color: #555;

    font-size: 25px;

    font-weight: 800;
}


.game-menu-text {
    display: block;

    font-size: clamp(21px, 3vw, 29px);

    line-height: 1.45;

    font-weight: 800;
}


.game-menu-subtext {
    display: block;

    margin-top: 5px;

    color: #888;

    font-size: 17px;

    font-weight: 700;
}


/* ============================================================
   ゲーム
   ============================================================ */

.game-screen {
    width: min(1100px, 100%);

    margin: 0 auto;
}


.game-header {
    display: flex;

    align-items: center;
    justify-content: center;

    margin-bottom: 24px;

    text-align: center;
}


.game-title {
    font-size: clamp(26px, 5vw, 38px);

    font-weight: 800;

    color: #444;
}


.game-content {
    width: 100%;
}


.question-card {
    width: 100%;

    max-width: 1000px;

    margin: 0 auto;

    padding:
        28px
        22px
        38px;

    border-radius: 32px;

    background: #fff;

    box-shadow:
        0 6px 22px rgba(0, 0, 0, 0.07);

    text-align: center;
}


.question-text {
    margin: 0 0 18px;

    font-size: clamp(25px, 5vw, 38px);

    font-weight: 800;

    color: #444;
}


.answer-message {
    min-height: 48px;

    margin: 12px 0;

    display: flex;

    align-items: center;
    justify-content: center;

    font-size: clamp(25px, 5vw, 34px);

    font-weight: 800;
}


.correct-message {
    color: #2e9d5b;
}


.wrong-message {
    color: #e05a52;
}


/* ============================================================
   次の問題ボタン
   ============================================================ */

.next-question-button {
    min-width: 250px;

    margin: 22px auto 0;

    padding: 17px 30px;

    border: none;

    border-radius: 22px;

    background: #ffb84d;

    color: #fff;

    font-family: inherit;

    font-size: 25px;

    font-weight: 800;

    line-height: 1.4;

    cursor: pointer;

    box-shadow:
        0 5px 0 #e29a2e,
        0 8px 16px rgba(0, 0, 0, 0.10);

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}


.next-question-button:hover {
    transform: translateY(-2px);
}


.next-question-button:active {
    transform: translateY(4px);

    box-shadow:
        0 1px 0 #e29a2e;
}


/* ============================================================
   共通：図形
   ============================================================ */

.shape-svg {
    display: block;

    width: 100%;
    height: 100%;
}


.shape-light {
    fill: #d9d9d9;

    stroke: #222;

    stroke-width: 4;

    stroke-linejoin: round;

    stroke-linecap: round;
}


/* ============================================================
   No.1
   ============================================================ */

.basic-shape-target {
    width: 250px;
    height: 250px;

    margin: 10px auto 30px;

    display: flex;

    align-items: center;
    justify-content: center;
}


.basic-shape-target svg {
    width: 220px;
    height: 220px;
}


.basic-shape-choice-grid {
    width: min(900px, 100%);

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        repeat(5, 1fr);

    gap: 14px;
}


.basic-shape-choice {
    min-height: 170px;

    padding: 15px;

    border: 4px solid #e5ddd4;

    border-radius: 24px;

    background: #fff;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}


.basic-shape-choice:hover:not(:disabled) {
    transform: translateY(-3px);

    background: #fffaf3;
}


.basic-shape-choice.correct {
    border-color: #50b878;

    background: #eaf9ef;
}


.basic-shape-choice.wrong {
    border-color: #e66b62;

    background: #fff0ef;

    opacity: 0.45;

    cursor: default;
}


.basic-shape-choice svg {
    width: 120px;
    height: 120px;
}


/* ============================================================
   No.2 かたはめ
   ============================================================ */

.fitting-board {
    position: relative;

    width: min(620px, 92vw);

    height: min(620px, 92vw);

    margin: 10px auto 25px;

    overflow: hidden;

    border: 5px solid #d8cec1;

    border-radius: 30px;

    background: #f4efe8;

    touch-action: none;
}


.fitting-hole {
    position: absolute;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 14px;

    pointer-events: none;

    z-index: 1;
}


.fitting-hole svg {
    width: 100%;
    height: 100%;
}


.fitting-hole .shape-light {
    fill: #ffffff;

    stroke: #777;

    stroke-width: 4;

    stroke-dasharray: 7 5;
}


.fitting-piece {
    position: absolute;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: grab;

    touch-action: none;

    user-select: none;

    z-index: 5;

    transition:
        filter 0.15s ease,
        transform 0.15s ease;
}


.fitting-piece.dragging {
    cursor: grabbing;

    z-index: 20;

    transform: scale(1.06);

    filter:
        drop-shadow(
            0 8px 8px
            rgba(0, 0, 0, 0.2)
        );
}


.fitting-piece.correct {
    cursor: default;

    z-index: 3;

    transform: none;

    opacity: 1;
}


.fitting-piece svg {
    width: 100%;
    height: 100%;
}


/* ============================================================
   No.3 スクラッチ
   ============================================================ */

.scratch-wrapper {
    position: relative;

    width: min(82vw, 500px);

    height: min(82vw, 500px);

    margin: 20px auto;

    overflow: hidden;

    border-radius: 30px;

    background: #fff;

    border: 5px solid #d5d5d5;

    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.10);
}


.scratch-hidden-shape {
    position: absolute;

    inset: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    z-index: 1;

    pointer-events: none;
}


.scratch-hidden-shape svg {
    width: 62%;
    height: 62%;
}


.scratch-hidden-name {
    position: absolute;

    left: 50%;
    bottom: 18px;

    transform: translateX(-50%);

    z-index: 2;

    color: #333;

    font-size: clamp(25px, 6vw, 38px);

    font-weight: 800;

    white-space: nowrap;

    opacity: 0;

    transition: opacity 0.9s ease;
}


.scratch-hidden-name.reveal {
    opacity: 1;
}


.scratch-canvas {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    z-index: 3;

    display: block;

    touch-action: none;

    cursor: crosshair;
}


.scratch-canvas.fade-out {
    opacity: 0;

    transition:
        opacity 0.9s ease;
}


.scratch-help {
    margin: 10px 0;

    color: #777;

    font-size: 19px;

    font-weight: 700;
}


/* ============================================================
   No.4 大きさ比較
   ============================================================ */

.comparison-area {
    width: min(900px, 94vw);

    margin: 25px auto;

    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 25px;
}


.comparison-shape-wrapper {
    min-height: 300px;

    padding: 15px;

    border: 4px solid #e6ddd4;

    border-radius: 28px;

    background: #fff;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease;
}


.comparison-shape-wrapper:hover {
    transform: translateY(-3px);

    background: #fffaf3;
}


.comparison-shape {
    width: 100%;
    height: 260px;

    display: flex;

    align-items: center;
    justify-content: center;
}


.comparison-shape svg {
    width: 100%;
    height: 100%;
}


.comparison-shape-wrapper.correct {
    border-color: #50b878;

    background: #eaf9ef;
}


.comparison-shape-wrapper.wrong {
    border-color: #e66b62;

    background: #fff0ef;
}


.comparison-answer-area {
    display: flex;

    justify-content: center;

    gap: 15px;
}


.comparison-answer-button {
    padding: 14px 25px;

    border: 3px solid #ddd2c6;

    border-radius: 20px;

    background: #fff;

    font-family: inherit;

    font-size: 22px;

    font-weight: 800;

    cursor: pointer;
}


/* ============================================================
   No.5 色＋図形
   ============================================================ */

.color-shape-target {
    width: 250px;
    height: 250px;

    margin: 10px auto 25px;

    display: flex;

    align-items: center;
    justify-content: center;
}


.color-shape-target svg {
    width: 220px;
    height: 220px;
}


.color-shape-choice-grid {
    width: min(900px, 100%);

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        repeat(5, 1fr);

    gap: 12px;
}


.color-shape-choice {
    min-height: 150px;

    padding: 10px;

    border: 4px solid #e5ddd4;

    border-radius: 22px;

    background: #fff;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;
}


.color-shape-choice:hover:not(:disabled) {
    background: #fffaf3;

    transform: translateY(-3px);
}


.color-shape-choice.correct {
    border-color: #50b878;

    background: #eaf9ef;
}


.color-shape-choice.wrong {
    border-color: #e66b62;

    background: #fff0ef;

    opacity: 0.45;

    cursor: default;
}


.color-shape-choice svg {
    width: 115px;
    height: 115px;
}


/* ============================================================
   No.6 / No.7
   ============================================================ */

.special-shape-target {
    width: 250px;
    height: 250px;

    margin: 10px auto 25px;

    display: flex;

    align-items: center;
    justify-content: center;
}


.special-shape-target svg {
    width: 220px;
    height: 220px;
}


.special-shape-choice-grid {
    width: min(900px, 100%);

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 15px;
}


.special-shape-choice {
    min-height: 230px;

    padding: 12px;

    border: 4px solid #e5ddd4;

    border-radius: 25px;

    background: #fff;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;
}


.special-shape-choice:hover:not(:disabled) {
    background: #fffaf3;

    transform: translateY(-3px);
}


.special-shape-choice.correct {
    border-color: #50b878;

    background: #eaf9ef;
}


.special-shape-choice.wrong {
    border-color: #e66b62;

    background: #fff0ef;

    opacity: 0.45;

    cursor: default;
}


.special-shape-choice svg {
    width: 150px;
    height: 150px;
}


/* ============================================================
   アニメーション
   ============================================================ */

.correct {
    animation:
        correctPop 0.35s ease;
}


.wrong {
    animation:
        wrongShake 0.3s ease;
}


@keyframes correctPop {

    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

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


@keyframes wrongShake {

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

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

    75% {
        transform: translateX(6px);
    }
}


/* ============================================================
   フッター
   ============================================================ */

.app-footer {
    width: 100%;

    padding: 20px 15px;

    text-align: center;

    color: #999;

    font-size: 15px;

    font-weight: 700;
}


.app-footer p {
    margin: 0;
}


/* ============================================================
   フォーカス
   ============================================================ */

button:focus-visible {
    outline: 4px solid #8ecae6;

    outline-offset: 3px;
}


/* ============================================================
   タブレット
   ============================================================ */

@media screen and (max-width: 800px) {

    .header-inner {
        grid-template-columns:
            110px 1fr 110px;
    }


    .game-menu {
        gap: 14px;
    }


    .basic-shape-choice-grid,
    .color-shape-choice-grid {
        grid-template-columns:
            repeat(3, 1fr);
    }


    .special-shape-choice-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


/* ============================================================
   スマートフォン
   ============================================================ */

@media screen and (max-width: 600px) {

    .main-content {
        padding:
            20px
            10px
            40px;
    }


    .header-inner {
        width: 96%;

        grid-template-columns:
            85px 1fr 85px;

        min-height: 62px;
    }


    .home-button {
        min-width: 72px;

        padding: 9px 10px;

        font-size: 16px;
    }


    .header-title {
        font-size: 22px;
    }


    .home-title {
        font-size: 35px;
    }


    .game-menu {
        grid-template-columns: 1fr;

        gap: 13px;
    }


    .game-menu-button {
        min-height: 110px;

        padding:
            18px
            18px
            18px
            72px;
    }


    .game-menu-text {
        font-size: 23px;
    }


    .question-card {
        padding:
            22px
            12px
            28px;
    }


    .next-question-button {
        width: 90%;

        min-width: 0;

        font-size: 22px;
    }


    /* No.1 */

    .basic-shape-target {
        width: 200px;
        height: 200px;
    }


    .basic-shape-target svg {
        width: 180px;
        height: 180px;
    }


    .basic-shape-choice-grid {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 10px;
    }


    .basic-shape-choice {
        min-height: 130px;
    }


    /* No.2 */

    .fitting-board {
        width: 92vw;
        height: 92vw;

        max-width: 520px;
        max-height: 520px;

        border-radius: 24px;
    }


    /* No.3 */

    .scratch-wrapper {
        width: 86vw;
        height: 86vw;

        max-width: 430px;
        max-height: 430px;
    }


    .scratch-help {
        font-size: 16px;
    }


    /* No.4 */

    .comparison-area {
        width: 94vw;

        gap: 10px;
    }


    .comparison-shape-wrapper {
        min-height: 210px;

        padding: 5px;

        border-radius: 20px;
    }


    .comparison-shape {
        height: 190px;
    }


    .comparison-answer-area {
        gap: 10px;
    }


    /* No.5 */

    .color-shape-target {
        width: 210px;
        height: 210px;
    }


    .color-shape-target svg {
        width: 180px;
        height: 180px;
    }


    .color-shape-choice-grid {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 10px;
    }


    .color-shape-choice {
        min-height: 125px;
    }


    /* No.6 / No.7 */

    .special-shape-target {
        width: 210px;
        height: 210px;
    }


    .special-shape-target svg {
        width: 180px;
        height: 180px;
    }


    .special-shape-choice-grid {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 10px;
    }


    .special-shape-choice {
        min-height: 180px;
    }


    .special-shape-choice svg {
        width: 125px;
        height: 125px;
    }

}


/* ============================================================
   小さなスマートフォン
   ============================================================ */

@media screen and (max-width: 380px) {

    .header-inner {
        grid-template-columns:
            72px 1fr 72px;
    }


    .home-button {
        min-width: 65px;

        font-size: 14px;
    }


    .header-title {
        font-size: 19px;
    }


    .game-menu-text {
        font-size: 21px;
    }

}


/* ============================================================
   タッチデバイス
   ============================================================ */

@media (hover: none) {

    .game-menu-button:hover,
    .basic-shape-choice:hover,
    .color-shape-choice:hover,
    .special-shape-choice:hover,
    .comparison-shape-wrapper:hover {

        transform: none;
    }

}


/* ============================================================
   印刷
   ============================================================ */

@media print {

    .app-header,
    .app-footer {
        display: none;
    }

}
