/* レスポンシブ対応 - モバイル・タブレット */

/* モバイル固定CTAバー */
.mobile-cta-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--button-face);
    border-top: 2px outset var(--button-face);
    padding: 8px;
    z-index: 1001;
}

.mobile-cta-btn {
    background: var(--accent);
    border: 2px outset var(--accent);
    color: var(--text-inverse);
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 4px;
    cursor: pointer;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-cta-btn:hover {
    background: #FF99DD;
}

.mobile-cta-btn:active {
    border: 2px inset var(--accent);
}

.mobile-cta-btn.cta-tokyo {
    background: var(--link);
    border-color: var(--link);
}

.mobile-cta-btn.cta-tokyo:hover {
    background: #33E6C4;
}

.mobile-cta-btn.cta-discord {
    background: #7289DA;
    border-color: #7289DA;
}

.mobile-cta-btn.cta-discord:hover {
    background: #99AAE5;
}

/* タブレット対応 (768px以下) */
@media (max-width: 768px) {
    .desktop-icons {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        top: 16px;
        left: 16px;
        right: 16px;
    }
    
    .desktop-icon {
        width: 60px;
        margin-bottom: 8px;
    }
    
    .icon-image {
        font-size: 24px;
    }
    
    .icon-label {
        font-size: 10px;
    }
    
    .window {
        min-width: 280px;
        max-width: calc(100vw - 40px);
    }
    
    .floating-cta {
        bottom: 120px;
        right: 16px;
    }
    
    .floating-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* モバイル対応 (480px以下) */
@media (max-width: 480px) {
    /* デスクトップアイコンを非表示 */
    .desktop-icons {
        display: none;
    }
    
    /* フローティングCTAを非表示 */
    .floating-cta {
        display: none;
    }
    
    /* モバイルCTAバーを表示 */
    .mobile-cta-bar {
        display: flex;
        gap: 4px;
    }
    
    /* タスクバーを調整 */
    .taskbar {
        bottom: 60px;
    }
    
    /* Startメニューの位置調整 */
    .start-menu {
        bottom: 102px;
    }
    
    /* ウィンドウをフルスクリーン風に */
    .window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 120px !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        border-radius: 0;
        box-shadow: none;
        z-index: 200;
    }
    
    .window.hidden {
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .window:not(.hidden) {
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
    }
    
    .window-content {
        padding-bottom: 80px;
        height: calc(100% - 32px - 80px);
    }
    
    /* Start buttonのラベルを短縮 */
    .start-button span:last-child {
        display: none;
    }
    
    .start-button {
        padding: 4px;
        min-width: 40px;
    }
    
    /* タスクバーアイテムのサイズ調整 */
    .taskbar-item {
        font-size: 11px;
        padding: 2px 6px;
        max-width: 100px;
    }
    
    /* タブボタンの調整 */
    .tab-btn {
        font-size: 12px;
        padding: 6px 8px;
    }
    
    /* 価格表の調整 */
    .price-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 12px;
    }
    
    .stock-badge {
        align-self: flex-end;
    }
    
    /* CTAボタンの調整 */
    .cta-button {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    /* 見どころセクションの調整 */
    .highlight-item {
        padding: 8px;
    }
    
    .highlight-item h4 {
        font-size: 13px;
    }
    
    .highlight-item p {
        font-size: 12px;
    }
    
    /* お客様の声の調整 */
    .testimonial {
        padding: 8px;
    }
    
    .testimonial blockquote {
        font-size: 13px;
    }
    
    /* FAQの調整 */
    .faq-item summary {
        font-size: 13px;
        padding: 6px;
    }
    
    .faq-item p {
        font-size: 12px;
        padding: 8px;
    }
}

/* 極小画面対応 (320px以下) */
@media (max-width: 320px) {
    .mobile-cta-btn {
        font-size: 10px;
        padding: 6px 2px;
    }
    
    .hero-section h1 {
        font-size: 20px;
    }
    
    .hero-section h2 {
        font-size: 14px;
    }
    
    .core-message {
        font-size: 13px;
        padding: 8px;
    }
    
    .window-content {
        padding: 12px;
    }
}

/* ランドスケープモード対応 */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-cta-bar {
        padding: 4px;
    }
    
    .mobile-cta-btn {
        padding: 4px 2px;
        font-size: 11px;
    }
    
    .taskbar {
        bottom: 40px;
    }
    
    .start-menu {
        bottom: 82px;
    }
    
    .window {
        bottom: 80px !important;
    }
}

/* アクセシビリティ強化 */
@media (prefers-reduced-motion: reduce) {
    .window {
        transition: none !important;
    }
    
    .floating-btn {
        transition: none !important;
    }
    
    .boot-screen .progress-fill {
        transition: none !important;
    }
}

/* ダークモード対応準備 */
@media (prefers-color-scheme: dark) {
    /* 将来的にダークテーマを追加する場合のプレースホルダー */
}

/* 印刷対応 */
@media print {
    .taskbar,
    .floating-cta,
    .mobile-cta-bar,
    .start-menu,
    .desktop-icons {
        display: none !important;
    }
    
    .window {
        position: static !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
        margin: 20px 0 !important;
        page-break-inside: avoid;
    }
    
    .window-header {
        background: #fff !important;
        color: #000 !important;
        border-bottom: 1px solid #000;
    }
    
    .window-controls {
        display: none !important;
    }
}

/* === Mobile UX 強化：共通タップ幅 & 安全域 === */
@media (pointer:coarse) {
  .menu-item,
  .cta-button,
  .mobile-cta-btn,
  .dialog-btn,
  .tab-btn { min-height: 48px; } /* 指で押しやすく */
  button, .cta-button, .dialog-btn { touch-action: manipulation; } /* ダブルタップズーム抑止 */
}

/* iPhoneホームバーの安全域を考慮 */
.mobile-cta-bar {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}

/* ダイアログ類がバーに被らないように */
.dialog .dialog-buttons {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px));
}

/* === ゲーム専用：オンスクリーンパッド & 余白 === */
/* キャンバスのスクロール/ズーム暴発を止める */
#zzi-cv { touch-action: none; image-rendering: pixelated; }

/* パッド本体（JSが #game-window .window-content 内に注入）*/
#zzi-pad {
  position: absolute; left: 0; right: 0;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: none; justify-content: center; gap: 12px; z-index: 5;
}
#zzi-pad .btn {
  border: 2px solid #111; background: #fff;
  padding: 12px 16px; font: 16px ui-monospace, monospace; border-radius: 10px;
}
@media (pointer:coarse) { #zzi-pad { display: flex; } }

/* ウィンドウ内の下詰めを拡げる（ゲーム時だけ） */
@media (max-width: 480px) {
  /* 既存：.window{ bottom:120px } に合わせ、コンテンツ内余白を増量 */
  #game-window .window-content {
    /* ヘッダー32px + 既存下80px では足りないため、Padぶん追加 */
    padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    height: auto; /* 既存height計算と競合させない */
  }

  /* Startメニュー／タスクバーも安全域対応に（既存値に足し込み） */
  .taskbar   { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .start-menu{ bottom: calc(102px + env(safe-area-inset-bottom, 0px)); }
}

/* 横持ち時はさらにパッドを詰める */
@media (max-height: 500px) and (orientation: landscape) {
  #game-window .window-content {
    padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  }
}

/* =========================
   Mobile/Tablet polish patch
   ========================= */

/* 共通：指で触る前提のタップ幅 / スクロール挙動 */
html, body { height: 100%; }
body { overscroll-behavior-y: none; }
button, .cta-button, .mobile-cta-btn, .tab-btn { min-height: 44px; }

/* iOS安全域 */
:root {
  --bar-task: 40px;     /* 既存タスクバー */
  --bar-cta: 56px;      /* モバイルCTAの高さ */
  --win-head: 32px;     /* ウィンドウ見出しの高さ */
  --safe: env(safe-area-inset-bottom, 0px);
}

/* タブレット（<= 768px） */
@media (max-width: 768px) {
  /* アイコンはグリッドで詰める */
  .desktop-icons {
    display: grid;
    grid-template-columns: repeat(4, minmax(68px, 1fr));
    gap: 14px;
    padding: 12px;
  }
  .desktop-icon { width: 100%; }
  .icon-image { font-size: 26px; }
  .icon-label { font-size: 10px; }

  /* フローティングCTAを少し小さく */
  .floating-cta { right: 12px; bottom: 120px; }
  .floating-btn { font-size: 12px; padding: 6px 10px; }
}

/* モバイル（<= 480px） */
@media (max-width: 480px) {
  /* ビューポートの高さは 100dvh を使ってアドレスバー問題を回避 */
  .desktop { height: 100dvh; }

  /* デスクトップアイコン＆浮遊CTAは隠す → 下バーに集約 */
  .desktop-icons, .floating-cta { display: none !important; }

  /* カウントダウン帯は上に固定（重なり防止） */
  .countdown-banner {
    position: sticky; top: 0; z-index: 2000;
    padding: 8px 6px;
  }

  /* モバイルCTAバーを常時表示 */
  .mobile-cta-bar {
    display: flex;
    gap: 6px;
    height: var(--bar-cta);
    padding: 8px 10px calc(8px + var(--safe));
    align-items: center;
  }
  .mobile-cta-btn { font-size: 13px; font-weight: 700; }

  /* タスクバーはCTAバーの上へオフセット */
  .taskbar {
    bottom: calc(var(--bar-cta) + var(--safe));
    height: var(--bar-task);
  }

  /* Startメニューは下ドロワー型に（被り回避） */
  .start-menu {
    left: 8px; right: 8px;
    bottom: calc(var(--bar-cta) + var(--bar-task) + var(--safe));
    width: auto;
    max-height: 60dvh;
  }

  /* ウィンドウ＝画面パネル化（1枚ずつフル） */
  .window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(var(--bar-cta) + var(--bar-task) + var(--safe)) !important;
    width: auto !important; height: auto !important;
    max-width: none !important; border-radius: 0;
    box-shadow: none; z-index: 1200;
    contain: layout paint; /* パフォ向上 */
    background: var(--window-bg);
  }

  /* スライド切替（非表示→右へ退避） */
  .window.hidden { transform: translateX(100%); transition: transform .28s ease; }
  .window:not(.hidden) { transform: translateX(0); transition: transform .28s ease; }

  /* 中身は単一スクロール。ダブルスクロール防止 */
  .window-content, .window-body {
    height: calc(100dvh - var(--win-head) - var(--bar-cta) - var(--bar-task) - var(--safe));
    overflow: auto;
    padding: 12px 14px 16px;
    -webkit-overflow-scrolling: touch;
  }

  /* タブ/表/ボタンの読みやすさ調整 */
  .tab-btn { flex: 1 1 0; font-size: 13px; padding: 8px 10px; }
  .price-row { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; }
  .cta-button { font-size: 14px; padding: 11px 14px; width: 100%; text-align: center; }
  .purchase-buttons { display: grid; gap: 8px; }

  /* チケットタブを上にピン留め（スクロール長対策） */
  .ticket-tabs { position: sticky; top: 0; z-index: 5; background: var(--window-bg); padding-top: 6px; }

  /* 画像ははみ出さない */
  img, video { max-width: 100%; height: auto; }

  /* Start ボタンの文字は省略 */
  .start-button span:last-child { display: none; }
  .start-button { padding: 4px; min-width: 40px; }

  /* FAQ / details 内のタイポ微調整 */
  .faq-item summary { font-size: 14px; padding: 8px 6px; }
  .faq-item p { font-size: 13px; padding: 8px 6px; }
}

/* 横持ち（高さが小さいとき）は下マージンを圧縮 */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --bar-cta: 48px; }
  .taskbar { bottom: calc(var(--bar-cta) + var(--safe)); }
  .window { bottom: calc(var(--bar-cta) + var(--bar-task) + var(--safe)) !important; }
  .window-content, .window-body {
  height: calc(100dvh - var(--win-head) - var(--bar-cta) - var(--bar-task) - var(--safe));
  }
}

/* ゲーム用：オンスクリーンパッドの余白（既存CSSを上書き） */
@media (max-width: 480px) {
  #game-window .window-content {
    padding-bottom: calc(140px + var(--safe));
    height: auto; /* 高さ計算と競合させない */
  }
}

/* モーション抑制（ユーザー設定尊重） */
@media (prefers-reduced-motion: reduce) {
  .window, .window.hidden, .window:not(.hidden) { transition: none !important; }
}

