/* =========================================================
   responsive.css
   ---------------------------------------------------------
   全メディアクエリをまとめたファイル。

   ブレークポイント：
     900px … 虹装飾を控えめに
     760px … クリックエリアと購買部を縦積みに切り替え
             （クリックエリア固定高・購買部だけスクロール）
     400px … さらに小さい端末用の微調整
   touch  … ツールチップをボトムシート表示に切り替え
   ========================================================= */

@media (max-width: 900px) {
  .rainbow { opacity: 0.85; }
  .band { height: 76px; }
}

@media (max-width: 760px) {
  /* 背景装飾を単純化 */
  .panel { left: 0; right: 0; top: 0; bottom: 0; transform: none; }
  .rainbow { display: none; }
  .bottom-line,
  .bottom { display: none; }

  /* ゲームを縦積みに切り替え */
  .game { flex-direction: column; }

  /* ── クリックエリア ──
     高さをコンテンツ量で決め、余白が出ないようにする。
     flex-shrink: 0 で購買部に押しつぶされるのを防ぎつつ、
     固定 height は持たない。overflow: hidden でコンテンツが
     購買部に侵食しないようにする。
     ※ .float-text は body 直下の fixed 要素なので hidden の影響を受けない。 */
  .click-area {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    padding: 10px 16px 6px;
    padding-top: calc(10px + env(safe-area-inset-top));
    justify-content: flex-start;
    overflow: hidden;
  }

  .count     { font-size: clamp(1.4rem, 7vw, 2rem); }
  .count-sub { margin-bottom: 6px; }
  .cps-info  { margin-top: 6px; }

  /* 転生ヒント・ボタンをコンパクトに */
  .prestige-hint { margin-top: 4px; font-size: 0.72rem; }
  .prestige-btn  { margin-top: 4px; min-height: 36px; padding: 6px 18px; font-size: 0.85rem; }

  .popkun-btn {
    width: clamp(120px, 38vw, 200px);
    height: clamp(86px, 27vw, 144px);
  }

  /* ── 購買部パネル ── */
  .shop {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-top: 3px solid #4b8bea;
  }

  /* ── アイテムアイコン ── */
  .item-icon-image { width: 40px; height: 40px; }

  /* ── アイテムテキスト ── */
  .item-name       { font-size: 0.9rem; }
  .item-production { font-size: 0.68rem; }
  .item-desc       { font-size: 0.72rem; }

  /* ── 実績トースト ── */
  .achievement-toast-container {
    top: calc(12px + env(safe-area-inset-top));
  }

  /* ── サポートカードグリッド ── */
  .passive-card-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .passive-card-icon .item-icon-image { width: 44px; height: 44px; }
}

/* ── 極端に狭い端末（400px 以下）── */
@media (max-width: 400px) {
  .click-area {
    padding: 8px 12px 4px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .popkun-btn {
    width: clamp(110px, 42vw, 170px);
    height: clamp(80px, 30vw, 122px);
  }

  /* 320px 以下ではサポートカードを 2 列固定にして崩れを防ぐ */
  .passive-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── タッチデバイス：ツールチップをボトムシートに ──
   hover が使えない端末では、ツールチップを画面最下部に
   シート状で表示する。pointer-events: auto を付けて
   スクロール操作できるようにする。 */
@media (hover: none) {
  .item-tooltip {
    left: 0 !important;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100%;
    max-width: 100%;
    max-height: min(55vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px 16px 0 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
  }

  /* 閉じるボタン分の余白を確保 */
  .item-tooltip .tooltip-title { padding-right: 32px; }

  .item-tooltip .tooltip-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #f5f5f5;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
  }

  /* ツールチップが画面下部を覆う分のスクロール余白 */
  .tooltip-margin { height: 192px; }
}
