/* 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    color: #333;
    overflow: auto;
}

/* 全体コンテナを1画面に収める */
.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #f8f9fa;
    overflow: visible;  /* 内部のはみ出しを許可 */
}

/* p5.jsのキャンバスを背面に配置 */
#canvas-container {
    flex: 0 0 60vh;
    min-height: 300px;
    width: 100%;
    background-color: #f8f9fa;
    position: relative;
}
#canvas-container canvas{
    position: absolute !important;
    top: 0;
    left: 0;
}
/* 下半分：プロフィールエリア */
.profile {
    flex: 1 0 auto;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #e2e8f0;
    padding: 40px 20px;
    background: #fff;
    box-sizing: border-box;
}

header h1 {
    font-size: 3rem;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    color: #1a365d; /* 信頼感のある濃紺 */
}

.subtitle {
    font-size: 1.1rem;
    color: #4a5568;
    margin-bottom: 2rem;
}

/* ボタンデザイン */
.links {
    display: flex;
    gap: 20px;
}

.btn {
    text-decoration: none;
    padding: 10px 25px;
    border: 1px solid #1a365d;
    color: #1a365d;
    border-radius: 4px;
    transition: all 0.3s;
    font-weight: bold;
}

.btn:hover {
    background-color: #1a365d;
    color: #fff;
}

.btn.highlight {
    background-color: #3182ce; /* 算数教材を強調する青 */
    color: #fff;
    border-color: #3182ce;
}

/* 共通ナビゲーション（ボタン） */
.footer-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #f4f7f6;
}

.footer-nav .btn {
    text-decoration: none;
    padding: 12px 20px;
    border: 1px solid #1a365d;
    color: #1a365d;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.9rem;
    transition: 0.3s;
    text-align: center;
}

.footer-nav .btn:hover {
    background: #1a365d;
    color: #fff;
}

.footer-nav .btn.active {
    background: #e2e8f0;
    border-color: #cbd5e0;
    color: #718096;
    pointer-events: none;
}

/* --- スマートフォン向け対応 --- */
@media screen and (max-width: 768px) {
    /* 1画面に収める制約を解除し、コンテンツに応じて伸びるようにする */
    html, body {
        overflow: auto; /* スクロールを許可 */
        height: auto;
        padding: 0 0 20px 0;
    }

    .wrapper {
        height: auto; /* コンテンツ量に合わせて高さを可変に */
        min-height: 100vh;
        overflow: visible;
    }

    /* 上半分のキャンバスエリアの高さ調整 */
    #canvas-container {
        flex: 0 0 300px; /* スマホでは高さを300pxに固定 */
        height: 300px;
    }

    /* 下半分のプロフィールエリア */
    .profile {
        flex: 1 0 auto;
        padding: 40px 20px;
        justify-content: flex-start; /* 上から順に並べる */
    }

    header h1 {
        font-size: 1.8rem; /* 文字サイズをスマホ向けに小さく */
        line-height: 1.2;
        margin-bottom: 10px;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 30px;
    }

    /* メニューを縦並びにする */
    .links {
        flex-direction: column; /* 横並びから縦並びへ */
        width: 100%;
        max-width: 300px; /* ボタンが横に広がりすぎないよう制限 */
        gap: 12px;
    }

    .btn {
        display: block;
        width: 100%; /* 横いっぱいに広げて押しやすく */
        padding: 15px; /* タップ領域を広く */
        text-align: center;
    }
    /* ナビゲーションの縦並び */
    .nav-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    .nav-links {
        margin-top: 5px;
    }

    .nav-links a {
        margin: 0 10px; /* 左右の余白を均等に */
    }

    .container {
        padding: 20px 15px;
        width: 98%;
    }

    /* 入力セクションの調整 */
    .input-section {
        gap: 15px;
        padding: 15px 10px;
    }

    input {
        width: 50px;
        font-size: 1.1rem;
    }

    /* 図解（SVG）を画面幅にフィットさせる */
    svg {
        width: 100%;
        height: auto; /* アスペクト比を維持して縮小 */
    }

    /* ボタンエリアを縦並びに */
    .btn-area {
        flex-direction: column;
        width: 100%;
    }

    button {
        width: 100%;
        min-width: unset !important;
    }

    .formula-display {
        font-size: 1.5rem;
    }

}