/* ===========================================
   Mobile Styles - Smartphone Layout (576px以下)
   =========================================== */

/* デフォルトは非表示 */
.mobile-hud,
.mobile-controls,
.mobile-bottom-hud,
.mobile-pause-btn {
  display: none !important;
}

/* 576px以下でモバイル専用レイアウトを適用 */
@media (max-width: 576px) {
  /* ダブルタップズームを無効化（Chrome対応強化） */
  html {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
  }

  body {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
  }

  * {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
  }
  /* サイドパネル非表示 */
  .side-panel {
    display: none !important;
  }

  /* フッター（操作説明）非表示 */
  #game-page > .container-fluid > .mt-2 {
    display: none !important;
  }

  /* モバイルHUD表示 */
  .mobile-hud {
    display: flex !important;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, var(--farm-cream) 100%);
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(93, 64, 55, 0.15);
  }

  .mobile-hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
  }

  /* 左側: ステータス（残り時間・親愛度・スコア） */
  .mobile-stats {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .mobile-stat {
    display: flex;
    align-items: baseline;
    gap: 2px;
  }

  .mobile-stat-label {
    font-size: 0.65rem;
    color: var(--farm-brown);
    font-weight: 500;
  }

  .mobile-stat-value {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--farm-green-dark);
  }

  .mobile-stat-value.timer-warning {
    color: #E53935;
    animation: pulse 0.5s ease-in-out infinite alternate;
  }

  /* モバイル用円形メーター */
  .mobile-meter {
    position: relative;
    width: 28px;
    height: 28px;
  }

  .mobile-meter svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
  }

  .mobile-meter-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 4;
  }

  .mobile-meter-bar {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 87.96;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.3s ease;
  }

  .mobile-meter-food .mobile-meter-bar {
    stroke: #FFB300;
  }

  .mobile-meter-water .mobile-meter-bar {
    stroke: #4FC3F7;
  }

  .mobile-meter-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.55rem;
    font-weight: bold;
    color: var(--farm-brown-dark);
  }

  /* 親愛度 */
  .mobile-affection {
    font-size: 1rem !important;
    font-weight: bold;
    color: #E57373;
  }

  /* 状態名 */
  .mobile-status {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: bold;
    white-space: nowrap;
    transition: all 0.3s ease;
  }

  .mobile-status-normal {
    background-color: var(--farm-green-pale);
    color: var(--farm-green-dark);
    border: 1px solid var(--farm-green-light);
  }

  .mobile-status-heat {
    background-color: #FFCDD2;
    color: #C62828;
    border: 1px solid #EF5350;
  }

  .mobile-status-lovesick {
    background-color: #E1BEE7;
    color: #6A1B9A;
    border: 1px solid #BA68C8;
  }

  .mobile-status-cold {
    background-color: #E3F2FD;
    color: #1565C0;
    border: 1px solid #90CAF9;
  }

  .mobile-status-obese {
    background-color: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFB74D;
  }

  /* 状態の残り秒数 */
  .mobile-status-timer {
    font-size: 0.65rem;
    opacity: 0.8;
    margin-left: 2px;
  }

  /* 右側: 所持アイテム */
  .mobile-items {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .mobile-item {
    font-size: 1.1rem;
    opacity: 0.35;
    filter: grayscale(80%);
    transition: all 0.2s;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .mobile-item[data-disabled="false"] {
    opacity: 1;
    filter: none;
  }


  /* ===========================================
     Mobile Bottom HUD - 盤面下のステータス表示
     （レイアウトはBootstrapユーティリティで制御）
     =========================================== */
  .mobile-bottom-hud {
    display: flex !important;
    width: 100%;
    max-width: 350px;
    margin-top: 8px;
  }

  .mobile-bottom-score-value {
    color: var(--farm-green-dark);
    min-width: 4rem;
  }

  /* メインレイアウト調整 */
  .d-flex.justify-content-center.align-items-start.gap-4 {
    flex-direction: column;
    align-items: center !important;
    gap: 0 !important;
  }

  /* ボードコンテナの調整 */
  #board-container {
    margin: 0 auto;
  }

  /* メッセージエリアの調整 */
  #message-area {
    font-size: 0.85rem;
    padding: 8px 12px !important;
    margin-bottom: 8px !important;
  }

  /* コンテナの余白削減 */
  .container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .card-body {
    padding: 8px !important;
  }

  /* 背景パネル（カード）を非表示 */
  #game-page .card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  #game-page .card-body {
    background: transparent !important;
  }

  /* Mobile Pause Button - 右下固定 */
  .mobile-pause-btn {
    display: flex !important;
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: 3px solid var(--farm-brown);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--farm-tan) 0%, var(--farm-brown-light) 100%);
    font-size: 1rem;
    z-index: 100;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
  }

  .mobile-pause-btn:active {
    transform: scale(0.95);
    background: linear-gradient(180deg, var(--farm-brown-light) 0%, var(--farm-brown) 100%);
  }
}
