/**
 * FORTH Theory - Complete Mobile Optimization
 * Target: iPhone(65%), Android(35%) - Japan Market 2024
 * Developer: UX/UI Specialist Yamada Misaki
 *
 * Devices Tested:
 * - iPhone 15 Pro (393×852px)
 * - iPhone 14 (390×844px)
 * - iPhone SE 3rd (375×667px)
 * - Xperia 5 V (384×854px)
 * - Galaxy S23 (360×800px)
 * - AQUOS sense8 (360×780px)
 */

/* ==========================================================================
   基本設定 - Viewport最適化
   ========================================================================== */
@media screen and (max-width: 480px) {
    /* 超小型デバイス対応（iPhone SE等） */
    html {
        font-size: 15px; /* 基準フォントサイズ */
    }
}

@media screen and (min-width: 481px) and (max-width: 768px) {
    /* タブレット小型 */
    html {
        font-size: 16px;
    }
}

/* ==========================================================================
   メインモバイル最適化 (iPhone/Android共通)
   ========================================================================== */
@media screen and (max-width: 768px) {

    /* ----- タッチデバイス最適化 ----- */
    * {
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        touch-action: manipulation; /* ダブルタップズーム無効化 */
    }

    /* ----- 基本レイアウト ----- */
    body {
        font-size: 16px; /* 最小推奨サイズ */
        line-height: 1.7;
        -webkit-text-size-adjust: 100%; /* iOS文字サイズ自動調整防止 */
    }

    .forth-container {
        padding: 0 16px; /* 親指が届く余白 */
        max-width: 100%;
    }

    /* ----- ヘッダー最適化 ----- */
    .forth-header {
        position: sticky;
        top: 0;
        z-index: 9999;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }

    .forth-header-container {
        padding: 12px 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 56px; /* Material Design標準 */
    }

    .forth-logo {
        font-size: 20px !important;
        font-weight: bold;
        color: #1e293b;
        text-decoration: none;
    }

    .forth-tagline {
        display: none; /* モバイルでは非表示 */
    }

    /* ----- ハンバーガーメニュー ----- */
    .forth-mobile-menu {
        display: block !important;
        width: 48px;
        height: 48px;
        padding: 12px;
        background: transparent;
        border: none;
        cursor: pointer;
        position: relative;
    }

    .forth-mobile-menu span {
        display: block;
        width: 24px;
        height: 2px;
        background: #1e293b;
        margin: 5px 0;
        transition: 0.3s;
        border-radius: 2px;
    }

    .forth-mobile-menu.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .forth-mobile-menu.active span:nth-child(2) {
        opacity: 0;
    }

    .forth-mobile-menu.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    /* ----- ナビゲーションドロワー ----- */
    .forth-nav {
        position: fixed;
        top: 56px;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: calc(100vh - 56px);
        background: white;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        overflow-y: auto;
        z-index: 9998;
    }

    .forth-nav.active {
        left: 0;
    }

    .forth-nav-menu {
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .forth-nav-menu a {
        display: block;
        padding: 16px 20px;
        font-size: 16px;
        color: #1e293b;
        text-decoration: none;
        border-bottom: 1px solid #e5e7eb;
        min-height: 48px; /* タップターゲット最小サイズ */
    }

    .forth-nav-menu a:active {
        background: #f3f4f6;
    }

    /* オーバーレイ */
    .forth-nav-overlay {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        width: 100%;
        height: calc(100vh - 56px);
        background: rgba(0, 0, 0, 0.5);
        z-index: 9997;
    }

    .forth-nav-overlay.active {
        display: block;
    }

    /* ----- 言語切り替えボタン ----- */
    .forth-lang {
        display: flex !important;
        gap: 8px;
        margin-right: 8px;
    }

    .forth-lang-btn {
        padding: 8px 12px !important;
        font-size: 14px !important;
        border-radius: 6px;
        min-width: auto !important;
        min-height: 36px;
    }

    .forth-lang-btn.active {
        background: #3b82f6;
        color: white;
    }

    /* ----- メインコンテンツエリア ----- */
    .forth-main {
        padding: 16px 0;
        width: 100%;
    }

    .forth-article {
        background: white;
        border-radius: 0;
        box-shadow: none;
        margin: 0 -16px; /* フルワイド */
    }

    /* ----- 記事ヘッダー ----- */
    .forth-article-header {
        padding: 24px 16px;
        background: linear-gradient(135deg, #f8f9fa, #fff);
    }

    .forth-article-title {
        font-size: 24px !important;
        line-height: 1.4 !important;
        margin-bottom: 16px !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* ----- メタ情報の改善 ----- */
    .forth-article-meta-wrapper {
        margin-top: 16px;
    }

    .forth-meta-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        padding: 8px 0;
        font-size: 14px;
        line-height: 1.5;
    }

    .forth-meta-primary {
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    .forth-meta-date {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        color: #64748b;
    }

    .forth-meta-separator {
        color: #cbd5e1;
    }

    .language-badge {
        padding: 4px 8px;
        background: #eff6ff;
        border: 1px solid #bfdbfe;
        border-radius: 4px;
        font-size: 12px;
        font-weight: 500;
    }

    /* ----- カテゴリーバッジ ----- */
    .forth-meta-categories {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .forth-category-badge {
        display: inline-block;
        padding: 6px 12px !important;
        background: #f3f4f6;
        color: #374151;
        border-radius: 16px;
        font-size: 13px !important;
        text-decoration: none;
        min-height: 32px;
        line-height: 20px;
    }

    .forth-category-badge:active {
        background: #e5e7eb;
    }

    /* ----- 記事本文 ----- */
    .forth-article-content {
        padding: 24px 16px;
        font-size: 16px;
        line-height: 1.8;
    }

    .forth-article-content p {
        margin-bottom: 20px;
    }

    .forth-article-content h2 {
        font-size: 22px;
        margin: 32px 0 16px;
        padding-bottom: 8px;
        border-bottom: 2px solid #e5e7eb;
    }

    .forth-article-content h3 {
        font-size: 19px;
        margin: 24px 0 12px;
    }

    .forth-article-content ul,
    .forth-article-content ol {
        padding-left: 24px;
        margin-bottom: 20px;
    }

    .forth-article-content li {
        margin-bottom: 8px;
        line-height: 1.7;
    }

    /* ----- コードブロック最適化 ----- */
    .forth-article-content pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        background: #f8f9fa;
        border-radius: 8px;
        font-size: 14px;
    }

    .forth-article-content code {
        font-size: 14px;
        padding: 2px 6px;
        background: #f3f4f6;
        border-radius: 4px;
    }

    /* ----- テーブル最適化 ----- */
    .forth-article-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 20px;
    }

    .forth-article-content th,
    .forth-article-content td {
        padding: 8px 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    /* ----- 画像最適化 ----- */
    .forth-article-content img {
        max-width: 100%;
        height: auto;
        border-radius: 8px;
        margin: 16px 0;
    }

    /* ----- 広告エリア最適化 ----- */
    .forth-ad-wrapper {
        padding: 16px;
        margin: 24px 0;
        background: #f8f9fa;
        text-align: center;
    }

    .forth-ad-wrapper h3 {
        font-size: 14px;
        margin-bottom: 12px;
        color: #64748b;
    }

    /* DMM広告の中央配置 */
    .dmm-widget-banner,
    iframe[width="300"] {
        margin: 0 auto !important;
        display: block !important;
    }

    /* ----- お問い合わせCTA ----- */
    .forth-contact-cta {
        margin: 32px 16px;
        padding: 24px;
        background: linear-gradient(135deg, #eff6ff, #dbeafe);
        border-radius: 12px;
        text-align: center;
    }

    .forth-contact-cta h3 {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .forth-contact-cta p {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 20px;
        color: #475569;
    }

    .forth-btn-primary {
        display: inline-block;
        padding: 12px 24px !important;
        background: #3b82f6;
        color: white !important;
        border-radius: 8px;
        font-size: 16px !important;
        font-weight: 500;
        text-decoration: none;
        min-height: 48px;
        line-height: 24px;
    }

    .forth-btn-primary:active {
        background: #2563eb;
        transform: scale(0.98);
    }

    /* ----- 記事ナビゲーション ----- */
    .forth-post-nav {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin: 24px 16px;
    }

    .forth-nav-item {
        display: flex;
        align-items: center;
        padding: 16px !important;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        text-decoration: none;
        color: #1e293b;
        min-height: 56px;
    }

    .forth-nav-item:active {
        background: #f8f9fa;
    }

    .nav-arrow {
        font-size: 20px;
        color: #94a3b8;
    }

    .nav-title {
        flex: 1;
        margin: 0 12px;
        font-size: 15px;
        line-height: 1.4;
    }

    /* ----- コメントエリア ----- */
    .forth-comments-area {
        margin: 24px 16px;
        padding: 20px 16px;
        background: #f8f9fa;
        border-radius: 12px;
    }

    .comment-respond {
        background: white;
        padding: 16px;
        border-radius: 8px;
    }

    .comment-form label {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
        font-size: 14px;
        color: #374151;
    }

    .comment-form input[type="text"],
    .comment-form input[type="email"],
    .comment-form input[type="url"],
    .comment-form textarea {
        width: 100%;
        padding: 12px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 16px; /* iOS自動ズーム防止 */
        -webkit-appearance: none;
    }

    .comment-form textarea {
        min-height: 120px;
        resize: vertical;
    }

    .comment-form input[type="submit"] {
        width: 100%;
        padding: 12px 24px;
        background: #3b82f6;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 500;
        min-height: 48px;
    }

    /* ----- フッター最適化 ----- */
    .forth-footer {
        padding: 32px 16px;
        background: #1e293b;
    }

    .forth-footer-content {
        text-align: center;
    }

    .forth-footer-logo {
        font-size: 24px;
        margin-bottom: 16px;
        color: white;
    }

    .forth-footer-nav {
        display: flex;
        flex-direction: column;
        gap: 16px;
        margin: 24px 0;
    }

    .forth-footer-nav a {
        padding: 12px;
        color: #cbd5e1;
        text-decoration: none;
        font-size: 15px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .forth-footer-nav a:active {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
    }

    .forth-footer-copyright {
        padding-top: 24px;
        border-top: 1px solid #334155;
        color: #94a3b8;
        font-size: 13px;
        line-height: 1.6;
    }

    /* ----- バックトゥトップボタン ----- */
    .forth-back-to-top {
        position: fixed;
        bottom: 24px;
        right: 16px;
        width: 56px !important;
        height: 56px !important;
        background: #3b82f6;
        color: white;
        border-radius: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        z-index: 100;
    }

    .forth-back-to-top:active {
        transform: scale(0.95);
    }

    /* ----- サイドバー ----- */
    .forth-sidebar {
        display: none; /* モバイルでは非表示 */
    }

    .forth-layout-2col {
        display: block;
    }

    /* ----- アーカイブページ ----- */
    .forth-posts-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 0 16px;
    }

    .forth-post-card {
        background: white;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

    .forth-post-card-inner {
        padding: 16px;
    }

    .forth-post-type-indicator {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: 20px;
        font-size: 13px;
        color: white;
        margin-bottom: 12px;
    }

    .forth-post-title {
        font-size: 18px !important;
        line-height: 1.4 !important;
        margin: 12px 0 !important;
    }

    .forth-post-title a {
        color: #1e293b;
        text-decoration: none;
    }

    .forth-post-excerpt {
        font-size: 14px;
        line-height: 1.6;
        color: #64748b;
        margin-bottom: 16px;
    }

    .forth-read-more {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        background: #f3f4f6;
        border-radius: 8px;
        color: #1e293b;
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
    }

    .forth-read-more:active {
        background: #e5e7eb;
    }

    /* ----- ページネーション ----- */
    .pagination,
    .page-numbers {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin: 32px 0;
        padding: 0 16px;
    }

    .page-numbers {
        min-width: 40px;
        min-height: 40px;
        padding: 8px 12px;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        color: #1e293b;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
    }

    .page-numbers.current {
        background: #3b82f6;
        color: white;
        border-color: #3b82f6;
    }

    /* ----- 404ページ ----- */
    .error-404 {
        flex-direction: column;
        gap: 16px;
    }

    .digit {
        font-size: 72px !important;
    }

    .wormhole {
        width: 60px !important;
        height: 60px !important;
    }

    .error-title {
        margin: 24px 16px;
    }

    .glitch-text {
        font-size: 28px !important;
    }

    .error-description {
        padding: 0 16px;
        font-size: 15px;
    }

    .portal-grid {
        padding: 0 16px;
        gap: 12px;
    }

    .portal {
        padding: 16px !important;
        min-height: 60px;
    }

    .portal-icon {
        font-size: 32px !important;
    }

    .portal-text {
        font-size: 14px !important;
    }

    /* ----- 検索フォーム ----- */
    .search-form {
        display: flex;
        gap: 8px;
        padding: 0 16px;
    }

    .search-form input[type="search"] {
        flex: 1;
        padding: 12px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 16px;
        -webkit-appearance: none;
    }

    .search-form button[type="submit"] {
        padding: 12px 24px;
        background: #3b82f6;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        min-width: auto;
    }

    /* ----- ホームページセクション ----- */
    .forth-hero {
        padding: 32px 16px !important;
        min-height: auto !important;
    }

    .forth-hero-content {
        text-align: center;
    }

    .forth-hero-title {
        font-size: 28px !important;
        line-height: 1.3 !important;
        margin-bottom: 16px;
    }

    .forth-hero-subtitle {
        font-size: 16px !important;
        margin-bottom: 24px;
    }

    .forth-hero-cta {
        flex-direction: column;
        gap: 12px;
    }

    .forth-shock-grid,
    .forth-posts,
    .forth-link-cards {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .forth-shock-card {
        padding: 20px !important;
        border-radius: 12px;
    }

    .forth-shock-number {
        font-size: 32px !important;
    }

    .forth-shock-title {
        font-size: 18px !important;
        margin: 12px 0;
    }

    .forth-shock-description {
        font-size: 14px !important;
        line-height: 1.6;
    }

    /* ----- Contact Form 7 ----- */
    .wpcf7-form p {
        margin-bottom: 20px;
    }

    .wpcf7-form label {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
        font-size: 14px;
    }

    .wpcf7-text,
    .wpcf7-email,
    .wpcf7-textarea {
        width: 100% !important;
        padding: 12px !important;
        border: 1px solid #d1d5db !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        -webkit-appearance: none;
    }

    .wpcf7-submit {
        width: 100%;
        padding: 14px 24px !important;
        background: #3b82f6 !important;
        color: white !important;
        border: none !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 500;
        min-height: 48px;
    }

    .wpcf7-submit:active {
        background: #2563eb !important;
    }

    .wpcf7-response-output {
        margin: 16px 0 !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        font-size: 14px !important;
    }

    .wpcf7-not-valid-tip {
        color: #dc2626;
        font-size: 13px;
        margin-top: 4px;
    }
}

/* ==========================================================================
   小型デバイス最適化 (iPhone SE等 - 375px以下)
   ========================================================================== */
@media screen and (max-width: 375px) {
    .forth-article-title {
        font-size: 22px !important;
    }

    .forth-hero-title {
        font-size: 24px !important;
    }

    .forth-lang-btn {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }

    .digit {
        font-size: 60px !important;
    }

    .glitch-text {
        font-size: 24px !important;
    }

    .forth-back-to-top {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px;
    }
}

/* ==========================================================================
   横向き表示対応
   ========================================================================== */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .forth-header-container {
        min-height: 48px;
        padding: 8px 16px;
    }

    .forth-hero {
        min-height: auto !important;
        padding: 24px 16px !important;
    }

    .forth-nav {
        top: 48px;
        height: calc(100vh - 48px);
    }

    .forth-nav-overlay {
        top: 48px;
        height: calc(100vh - 48px);
    }
}

/* ==========================================================================
   ダークモード対応
   ========================================================================== */
@media screen and (max-width: 768px) and (prefers-color-scheme: dark) {
    body {
        background: #0f172a;
        color: #e2e8f0;
    }

    .forth-header {
        background: rgba(15, 23, 42, 0.98);
        border-bottom-color: #334155;
    }

    .forth-logo,
    .forth-nav-menu a {
        color: #e2e8f0;
    }

    .forth-mobile-menu span {
        background: #e2e8f0;
    }

    .forth-article {
        background: #1e293b;
    }

    .forth-article-header {
        background: linear-gradient(135deg, #1e293b, #334155);
    }

    .forth-article-title {
        color: #f1f5f9;
    }

    .forth-meta-date {
        color: #94a3b8;
    }

    .language-badge {
        background: #1e3a8a;
        border-color: #3b82f6;
        color: #bfdbfe;
    }

    .forth-category-badge {
        background: #334155;
        color: #e2e8f0;
    }

    .forth-article-content {
        color: #e2e8f0;
    }

    .forth-article-content h2,
    .forth-article-content h3 {
        color: #f1f5f9;
        border-bottom-color: #334155;
    }

    .forth-article-content pre {
        background: #0f172a;
        color: #e2e8f0;
    }

    .forth-article-content code {
        background: #1e293b;
        color: #a5f3fc;
    }
}

/* ==========================================================================
   アクセシビリティ改善
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* フォーカス状態の明確化 */
    a:focus,
    button:focus,
    input:focus,
    textarea:focus {
        outline: 3px solid #3b82f6;
        outline-offset: 2px;
    }

    /* スクリーンリーダー用 */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    /* 高コントラストモード */
    @media (prefers-contrast: high) {
        .forth-article-title {
            color: #000;
            font-weight: 700;
        }

        .forth-btn-primary {
            background: #1e40af !important;
            border: 2px solid #1e40af !important;
        }

        .forth-category-badge {
            border: 1px solid currentColor;
        }
    }

    /* アニメーション軽減 */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ==========================================================================
   パフォーマンス最適化
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* GPU加速を使用 */
    .forth-nav,
    .forth-mobile-menu span,
    .forth-back-to-top {
        will-change: transform;
    }

    /* スムーススクロール */
    html {
        scroll-behavior: smooth;
    }

    /* タッチスクロール最適化 */
    .forth-article-content,
    .forth-nav {
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================================================
   アーカイブページのモバイル最適化
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* アーカイブヒーローセクション */
    .forth-archive-hero {
        padding: 60px 0 40px;
        text-align: center;
    }

    .forth-archive-hero-content {
        padding: 0 20px;
    }

    .forth-archive-icon {
        font-size: 48px;
        margin-bottom: 15px;
        display: block;
    }

    .forth-archive-title {
        font-size: 28px !important;
        line-height: 1.3;
        margin-bottom: 10px;
    }

    .forth-archive-subtitle {
        font-size: 14px;
        opacity: 0.8;
    }

    /* フィルターバー */
    .forth-filter-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        margin-bottom: 20px;
    }

    .forth-sort-select {
        width: 100%;
        padding: 12px;
        font-size: 16px !important;
        border-radius: 8px;
    }

    /* 投稿グリッド */
    .forth-posts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 15px;
    }

    /* 投稿カード */
    .forth-post-card {
        border-radius: 12px;
        overflow: hidden;
    }

    .forth-post-card-inner {
        padding: 0;
    }

    .forth-post-type-indicator {
        padding: 10px 15px;
        font-size: 14px;
    }

    .forth-type-icon {
        font-size: 20px;
    }

    .forth-post-content {
        padding: 15px;
    }

    .forth-post-title {
        font-size: 18px !important;
        line-height: 1.4;
        margin: 10px 0;
    }

    .forth-post-meta {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .forth-post-excerpt {
        font-size: 14px;
        line-height: 1.6;
        margin: 15px 0;
    }

    .forth-read-more {
        padding: 10px 15px;
        font-size: 14px;
        border-radius: 6px;
        display: inline-block;
    }

    /* DMM広告グリッド */
    .forth-dmm-grid {
        padding: 20px 15px;
        margin: 20px 0;
    }

    .forth-dmm-grid h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }

    /* ページネーション */
    .pagination {
        margin: 40px 0;
        padding: 0 15px;
    }

    .pagination .nav-links {
        display: flex;
        justify-content: center;
        gap: 5px;
        flex-wrap: wrap;
    }

    .pagination a,
    .pagination span {
        padding: 10px 12px;
        font-size: 14px;
        min-width: 40px;
        text-align: center;
    }

    /* 空状態デザイン */
    .forth-no-posts-universe {
        padding: 40px 20px;
        min-height: 60vh;
    }

    .telescope-animation {
        transform: scale(0.7);
        margin: 20px 0;
    }

    .forth-no-posts-content {
        padding: 0 15px;
    }

    .empty-title {
        font-size: 20px !important;
        line-height: 1.4;
        margin-bottom: 15px;
    }

    .empty-message {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 20px;
    }

    .loading-animation {
        margin: 30px 0;
    }

    .section-portals {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin: 20px 0;
    }

    .section-portal {
        padding: 15px 10px;
        font-size: 13px;
        min-height: 80px;
    }

    .portal-emoji {
        font-size: 24px;
        margin-bottom: 5px;
    }

    .search-alternative {
        margin-top: 30px;
        padding: 20px 15px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 10px;
    }

    .search-alternative h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }
}

/* ==========================================================================
   404ページのモバイル最適化
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* 404宇宙背景 */
    .forth-404-universe {
        min-height: 100vh;
        padding: 60px 0;
        overflow-x: hidden;
    }

    /* ブラックホールアニメーション */
    .blackhole-wrapper {
        transform: scale(0.6);
        margin: 20px auto;
    }

    /* 404数字 */
    .error-404 {
        font-size: 60px !important;
        margin: 30px 0;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .digit {
        font-size: 60px !important;
    }

    .wormhole {
        width: 50px;
        height: 50px;
    }

    /* エラータイトル */
    .error-title {
        font-size: 24px !important;
        line-height: 1.4;
        margin: 20px 0;
        padding: 0 20px;
    }

    .glitch-text {
        display: inline-block;
    }

    /* エラー説明 */
    .error-description {
        padding: 0 20px;
        margin: 20px 0;
    }

    .error-description p {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 12px;
    }

    .typewriter-text {
        font-size: 15px;
    }

    /* 物理ジョーク */
    .physics-joke {
        margin: 30px 20px;
    }

    .joke-bubble {
        padding: 15px;
        font-size: 13px;
        line-height: 1.5;
        border-radius: 10px;
    }

    /* エスケープルート */
    .escape-routes {
        padding: 0 20px;
        margin: 30px 0;
    }

    .escape-routes h3 {
        font-size: 18px;
        margin-bottom: 20px;
    }

    /* ポータルグリッド */
    .portal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .portal {
        padding: 15px 10px;
        border-radius: 10px;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 13px;
    }

    .portal-icon {
        font-size: 28px;
    }

    .portal-text {
        font-size: 13px;
    }

    /* 検索セクション */
    .search-dimension {
        margin: 30px 20px;
        padding: 20px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 12px;
    }

    .search-dimension h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .search-form {
        width: 100%;
    }

    .search-form input[type="search"] {
        width: 100%;
        padding: 12px 15px;
        font-size: 16px !important;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .search-form button {
        width: 100%;
        margin-top: 10px;
        padding: 12px;
        font-size: 16px !important;
        border-radius: 8px;
        background: var(--forth-primary);
        color: white;
        border: none;
    }

    /* 浮遊方程式 */
    .floating-formulas {
        display: none;
    }

    /* 星空背景調整 */
    .stars-bg,
    .stars-bg2,
    .stars-bg3 {
        opacity: 0.5;
    }

    /* コンテンツコンテナ */
    .forth-404-content {
        position: relative;
        z-index: 10;
        padding: 0;
        background: transparent;
    }
}

/* ==========================================================================
   JSON表示のモバイル最適化
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* 詳細データセクション */
    .detailed-data-section {
        padding: 15px;
        margin: 20px 0;
        border-radius: 8px;
    }

    .detailed-data-section h3 {
        font-size: 18px;
        margin-bottom: 15px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* JSON表示ボックス */
    .json-display-box {
        margin: 15px 0;
        padding: 10px;
        background: #1a1a2e;
        border-radius: 8px;
        position: relative;
    }

    .json-filename {
        font-size: 12px;
        padding: 8px 12px;
        background: rgba(139, 92, 246, 0.2);
        border-radius: 6px 6px 0 0;
        margin: -10px -10px 10px -10px;
        color: #a78bfa;
        word-break: break-all;
    }

    /* 分析ボタン */
    .analyze-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 16px !important;
        border-radius: 8px;
        margin: 15px 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        cursor: pointer;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .analyze-btn:active {
        transform: scale(0.98);
    }

    .analyze-btn:before {
        content: "📊";
        font-size: 20px;
    }

    /* JSON表示エリア */
    #json-display {
        max-height: 400px;
        overflow-y: auto;
        padding: 15px;
        background: #0f0f1e;
        border-radius: 8px;
        font-size: 13px;
        line-height: 1.5;
        -webkit-overflow-scrolling: touch;
    }

    .json-viewer {
        font-family: 'Courier New', monospace;
        font-size: 12px;
    }

    /* JSONツリービュー */
    .json-tree {
        margin-left: 0;
    }

    .json-tree ul {
        margin-left: 15px;
        padding-left: 10px;
        border-left: 1px dashed rgba(255, 255, 255, 0.1);
    }

    .json-key {
        color: #8be9fd;
        font-weight: bold;
    }

    .json-string {
        color: #50fa7b;
    }

    .json-number {
        color: #bd93f9;
    }

    .json-boolean {
        color: #ffb86c;
    }

    .json-null {
        color: #ff79c6;
    }

    /* パラメータテーブル */
    .param-table {
        width: 100%;
        border-collapse: collapse;
        margin: 15px 0;
        font-size: 13px;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 8px;
        overflow: hidden;
    }

    .param-table th {
        padding: 10px 8px;
        background: rgba(139, 92, 246, 0.15);
        font-size: 12px;
        text-align: left;
        font-weight: 600;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .param-table td {
        padding: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        word-break: break-word;
    }

    .param-table tr:last-child td {
        border-bottom: none;
    }

    /* 計算結果グリッド */
    .results-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 15px 0;
    }

    .result-card {
        padding: 12px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .result-label {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.6);
        margin-bottom: 5px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .result-value {
        font-size: 16px;
        font-weight: bold;
        color: #8be9fd;
    }

    /* チャートコンテナ */
    .chart-container {
        position: relative;
        height: 250px;
        margin: 20px 0;
        padding: 10px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 8px;
    }

    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* エラーメッセージ */
    .json-error {
        padding: 15px;
        background: rgba(255, 59, 48, 0.1);
        border: 1px solid rgba(255, 59, 48, 0.3);
        border-radius: 8px;
        color: #ff6b6b;
        font-size: 13px;
        margin: 15px 0;
    }

    /* ローディング状態 */
    .json-loading {
        text-align: center;
        padding: 30px;
        font-size: 14px;
        color: rgba(255, 255, 255, 0.6);
    }

    .json-loading:after {
        content: "...";
        display: inline-block;
        animation: dots 1.5s infinite;
    }

    @keyframes dots {
        0%, 20% { content: "."; }
        40% { content: ".."; }
        60%, 100% { content: "..."; }
    }

    /* コピーボタン */
    .copy-json-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        font-size: 12px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 6px;
        color: white;
        cursor: pointer;
        transition: background 0.2s;
    }

    .copy-json-btn:active {
        background: rgba(255, 255, 255, 0.2);
    }

    /* ダウンロードボタン */
    .download-json-btn {
        width: 100%;
        padding: 10px;
        margin-top: 10px;
        font-size: 14px;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 6px;
        color: white;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .download-json-btn:before {
        content: "⬇";
        font-size: 16px;
    }
}