/* ==========================================
   SP版レイアウト（スマホ・幅768px以下）
   style.css の後に読み込む
   ========================================== */

@media (max-width: 768px) {

    /* ---------- 全体 ---------- */

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
    }

    img {
        max-width: 100%;
        height: auto;
    }


    /* ---------- ヘッダー ---------- */

    header {
        padding: 0;
    }

    .nav {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 56px;
        padding: 6px 12px;
    }

    /* ロゴ：左側に固定 */

    .nav .logo-link {
        display: block;
        flex-shrink: 0;
        width: auto;
        margin: 0;
        padding: 0;
        line-height: 0;
    }

    .nav .logo {
        display: block;
        width: 160px;
        max-width: 100%;
        height: auto;
    }

    /* メニュー：常に配置しておき、透明にして隠す */

    .nav ul {
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 100;

        display: flex;
        flex-direction: column;
        align-items: stretch;

        width: 100%;
        height: auto;
        margin: 0;
        padding: 8px 12px;
        list-style: none;

        background: #1abc9c;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);

        /* 閉じた状態 */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        pointer-events: none;

        /* 閉じるとき：アニメが終わってから visibility を切る */
        transition:
            opacity 0.25s ease,
            transform 0.25s ease,
            visibility 0s linear 0.25s;
    }

    /* メニューを開いた状態 */

    .nav ul.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;

        /* 開くとき：visibility はすぐ表示 */
        transition:
            opacity 0.25s ease,
            transform 0.25s ease,
            visibility 0s;
    }

    .nav li {
        display: block;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
    }

    /* ハンバーガーボタン：右側 */

    .menu-button {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        flex-shrink: 0;
        gap: 5px;

        width: 44px;
        height: 44px;
        margin: 0;
        padding: 10px;

        border: none;
        border-radius: 4px;
        background: transparent;
        cursor: pointer;
    }

    .menu-button span {
        display: block;
        width: 24px;
        height: 2px;
        border-radius: 2px;
        background: #fff;
        transition:
            transform 0.3s ease,
            opacity 0.2s ease;
    }

    /* 開いたとき：上の線 */
    .menu-button.is-open span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    /* 開いたとき：真ん中の線 */
    .menu-button.is-open span:nth-child(2) {
        opacity: 0;
    }

    /* 開いたとき：下の線 */
    .menu-button.is-open span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .menu-button:hover {
        background: rgba(255, 255, 255, 0.12);
    }

    /* メニュー項目 */

    .nav ul li a {
        display: block;
        width: 100%;
        margin: 0;
        padding: 14px 8px;

        color: #fff;
        font-size: 14px;
        font-weight: bold;
        text-align: left;
        text-decoration: none;

        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }

    .nav ul li:last-child a {
        border-bottom: none;
    }

    .nav ul li a:hover {
        background: rgba(0, 0, 0, 0.08);
    }


    /* ---------- 説明文 ---------- */

    .site-description {
        margin: 12px;
        padding: 14px;
        font-size: 14px;
        line-height: 1.7;
    }

    .site-description h2 {
        margin-top: 0;
        font-size: 18px;
    }

    .site-description p {
        line-height: 1.7;
    }


    /* ---------- メインレイアウト ---------- */

    main {
        padding: 12px;
    }

    .container {
        display: flex;
        flex-direction: column;
        gap: 24px;
        margin-top: 0;
        padding: 12px;
    }

    .content,
    .sidebar {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .content h2,
    .sidebar h2 {
        font-size: 18px;
    }


    /* ---------- ゲーム一覧 ---------- */

    .game-list {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .game-card {
        min-width: 0;
        padding: 12px;
        border-radius: 10px;
    }

    .game-card:hover {
        transform: none;
    }

    .game-card:active {
        transform: scale(0.98);
    }

    .game-card a {
        display: block;
        color: inherit;
    }

    .game-card img {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 8px;
    }

    .game-card h3 {
        top: 60%;
        left: 50%;
        max-width: 100%;
        font-size: 1.15rem;
        white-space: normal;
        overflow-wrap: anywhere;

        text-shadow:
            0 2px 0 rgba(0, 0, 0, 0.8),
            0 4px 0 rgba(80, 80, 80, 0.7),
            0 8px 16px rgba(0, 0, 0, 0.6),
            0 0 12px rgba(255, 255, 255, 0.5);
    }

    .game-card p {
        margin-bottom: 0;
        color: #000;
        font-size: 14px;
        line-height: 1.6;
        text-align: left;
    }


    /* ---------- お知らせ ---------- */

    .timeline {
        padding: 10px 12px;
        line-height: 1.6;
    }

    .date {
        font-size: 12px;
    }

    .more-link {
        margin-top: 10px;
        font-size: 14px;
    }


    /* ---------- 広告 ---------- */

    .ad-banner {
        margin: 12px 0;
        padding: 0 12px;
        text-align: center;
    }

    .ad-banner a {
        display: inline-block;
        max-width: 100%;
    }

    .ad-banner a img {
        display: block;
        width: 100%;
        max-width: 728px;
        height: auto;
    }

    .ad-label {
        font-size: 12px;
        color: gray;
        text-align: center;
    }

    .side-ad {
        margin-bottom: 15px;
        text-align: center;
    }

    .side-ad a {
        display: inline-block;
        max-width: 100%;
    }


    /* ---------- フッター ---------- */

    footer {
        padding: 12px;
        font-size: 12px;
        line-height: 1.7;
        overflow-wrap: anywhere;
    }

    footer p {
        margin: 8px 0;
    }

    footer a {
        color: #fff;
        text-decoration: none;
    }


    /* ---------- PC版・SP版の表示切り替え ---------- */

    .pc-only {
        display: none !important;
    }

    .sp-only {
        display: flex;
    }
}


/* ==========================================
   小さめスマホ（幅400px以下）
   ========================================== */

@media (max-width: 400px) {

    .nav .logo {
        width: 140px;
    }

    .nav ul li a {
        padding: 12px 8px;
        font-size: 13px;
    }

    .site-description {
        margin: 10px;
        padding: 12px;
    }

    .game-card {
        padding: 10px;
    }

    .game-card h3 {
        font-size: 1rem;
    }

    footer {
        font-size: 11px;
    }
}


/* ==========================================
   動きを減らす設定のユーザー向け
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    .nav ul,
    .nav ul.is-open,
    .menu-button span {
        transition: none;
    }
}