/* ==========================================================================
   play.css：対戦画面レイアウト・操作パネル・色選択・重ね出し全統合版
   ========================================================================== */
#プレイ画面 {
  height: 100vh;
  height: 100dvh;
  /* スマホのアドレスバーの変化にも追従 */
  overflow: hidden;
  /* プレイ画面は絶対にスクロールさせない */
  justify-content: space-between;
}

/* 1. プレイ画面最上部バー */
.play-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* スマホの検索バー・ノッチ・時計などを自動検知して余白を確保*/
  padding-top: max(var(--auto-header-pt, 20px), calc(env(safe-area-inset-top, 0px) + 12px));
  padding-bottom: 10px;
  padding-left: max(14px, env(safe-area-inset-left, 14px));
  padding-right: max(14px, env(safe-area-inset-right, 14px));
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.back-btn:active {
  transform: scale(0.95);
  background: rgba(255, 50, 50, 0.5);
}

.room-indicator {
  font-size: 12px;
  color: #ffcc00;
  font-weight: bold;
}

/* 2. 対戦相手エリア（2人時は中央寄せ） */
.opponents-area {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.25);
  min-height: 64px;
  align-items: center;
}

.opponents-area.two-players {
  justify-content: center;
}

.opponent-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  min-width: 140px;
  transition: all 0.3s;
}

.opponents-area.two-players .opponent-box {
  min-width: 170px;
}

.opponent-box.reach {
  border-color: #ff3333;
  background: rgba(255, 0, 0, 0.2);
  box-shadow: 0 0 12px rgba(255, 50, 50, 0.6);
  animation: 警告アニメーション 1s infinite alternate;
}

@keyframes 警告アニメーション {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.03);
  }
}

.opp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.count-text.normal {
  font-size: 12px;
  color: #ffcc00;
}

.count-text.reach-text {
  font-size: 12px;
  color: #ff5555;
  font-weight: bold;
}

.opp-cards-visual {
  display: flex;
  margin-left: 6px;
  height: 28px;
  align-items: center;
}

.mini-card-back {
  width: 20px;
  height: 30px;
  background: #0d0d0d;
  border: 1.5px solid #ffffff;
  border-radius: 4px;
  margin-left: -10px;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.mini-card-back::before {
  content: "";
  width: 85%;
  height: 65%;
  background: linear-gradient(135deg, #ff1a1a 0%, #bb0000 100%);
  border-radius: 50%;
  transform: rotate(-25deg);
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.5);
}

.mini-card-back:first-child {
  margin-left: 0;
}

/* 3. 中央テーブル */
.table-area {
  flex: 1;
  min-height: 0;
  /* 親フレックスコンテナを突き破らないように伸縮を許可 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}


/* メッセージバッジをコンパクト化 */
.status-badge {
  font-size: 18px;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.75);
  padding: 8px 24px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  text-align: center;
}



/* 自分の手番のとき：特大20px ＆ 鮮やかな黄色でピカピカ点滅！ */
.status-badge.my-turn {
  font-size: 20px !important;
  font-weight: 900 !important;
  background: linear-gradient(135deg, #ffea00, #ffaa00) !important;
  color: #111111 !important;
  border-color: #ffffff !important;
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.9) !important;
  animation: 手番アピール 0.8s infinite alternate ease-in-out !important;
}

@keyframes 手番アピール {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.08);
  }
}


/* 相手のミニ裏面カードのラッパー（枠サイズを固定し、はみ出しを隠す） */
.mini-uno-card-wrapper {
  width: 16px;
  height: 24px;
  margin-left: -8px;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 3px;
  border: 1px solid #ffffff;
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
  background: #0d0d0d;
}

.mini-uno-card-wrapper:first-child {
  margin-left: 0;
}

/* 本物の裏面デザインを縮小して枠内に収める */
.mini-uno-card-wrapper .uno-card.real-uno-back {
  width: 82px;
  height: 124px;
  transform: scale(0.2);
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  border: none;
  box-shadow: none;
}

/* ---------------------------------------------------------------------- */
/* スマホなど縦の高さが狭い画面（高さ750px以下）の自動縮小スタイル */
/* ---------------------------------------------------------------------- */
@media (max-height: 750px) {

  .table-cards {
    gap: 24px;
    transform: translateX(-40px) scale(0.9);
  }

  .my-area {
    padding: 6px 0 10px 0;
  }

  .draw-button,
  .uno-button,
  .pass-button {
    padding: 6px 14px;
    font-size: 13px;
  }

  .hand-container {
    padding: 14px 10px 4px 10px;
    gap: 8px;
  }

  .hand-container .uno-card {
    width: 74px;
    height: 112px;
  }
}




/* ① 手札エリアの背景 */
.my-area {
  background: rgba(0, 0, 0, 0.45);
  padding-top: 10px;
  /* 下部検索バー・ホームバー対策（最低20px） */
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  position: relative;
  z-index: 100;
}

/* ② 「1まいひく」ボタンの青いグラデーション背景を復活！ */
.draw-button {
  background: linear-gradient(135deg, #2b6cb0, #1a365d);
  color: #fff;
  border: 2px solid #63b3ed;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap !important;
  flex-shrink: 0;
  transition: all 0.2s;

}

/* ③ 手札コンテナの横並びスクロール設定を復活！ */
.hand-container {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 24px 16px 10px 16px;
  -webkit-overflow-scrolling: touch;
}



/* ワイルド指定色バッジ */
.current-color-badge {
  display: none;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 14px;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}


/* ドロー攻撃残数バッジ */
.draw-penalty-badge {
  background: linear-gradient(135deg, #ff0000, #990000);
  border: 2px solid #ffcc00;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 16px;
  border-radius: 12px;
  box-shadow: 0 0 14px rgba(255, 0, 0, 0.8);
  animation: ドロー点滅 0.8s infinite alternate;
}

@keyframes ドロー点滅 {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.05);
  }
}

.table-cards {
  display: flex;
  gap: 36px;
  align-items: center;
  transform: translateX(-45px);
}


.my-control-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px 8px 16px;
}

.my-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.my-info br {
  display: none;
}

.sort-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.sort-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.35);
}

.action-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}


.draw-button.must-draw {
  background: linear-gradient(135deg, #e53e3e, #dd6b20);
  border-color: #ffeb3b;
  box-shadow: 0 0 16px 4px #ff5722;
  animation: 引くボタンアピール 0.8s infinite alternate;
}

@keyframes 引くボタンアピール {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.08);
  }
}

.uno-button {
  background: linear-gradient(135deg, #cc0000, #ff4400);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 900;
  font-style: italic;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  white-space: nowrap !important;
  flex-shrink: 0;
  transition: all 0.2s;
}

.uno-button.ready {
  background: linear-gradient(135deg, #ff0000, #ffff00);
  color: #111;
  border-color: #ffff00;
  box-shadow: 0 0 20px 6px #ff3300;
  animation: 発光シェイク 0.6s infinite alternate;
}

@keyframes 発光シェイク {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(1.1) rotate(-3deg);
  }
}



/* 5. 手札右上の「x2」重ね出しバッジ */
.card-duplicate-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ff0000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 900;
  padding: 1px 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
  z-index: 10;
}



.color-modal-dialog {
  pointer-events: auto;
  /* 色ボタンだけタップできるようにする */
  background: #222;
  border: 3px solid #ffcc00;
  border-radius: 20px;
  padding: 16px 18px;
  width: 100%;
  max-width: 270px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.9);
}

.color-modal-title {
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-choice-btn {
  padding: 12px 8px;
  border: 2px solid #fff;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}


.uno-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(80%);
  box-shadow: none;
  animation: none;
}

.color-choice-btn:active {
  transform: scale(0.92);
}

.modal-dialog {
  background: #222;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.modal-title {
  font-size: 16px;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 12px;
  color: #ccc;
  margin-bottom: 18px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

.modal-btn.cancel {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid #777;
  color: #fff;
}

.modal-btn.confirm {
  background: #ea2b2b;
  border: 1px solid #ff7777;
  color: #fff;
}


.draw-btn-card-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 32px;
  position: relative;
  flex-shrink: 0;
}

/* 山札カード全体をそのままミニチュア化 */
.draw-btn-card-wrapper .uno-card.real-uno-back {
  position: absolute;
  transform: scale(0.25);
  transform-origin: center center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.discard-pile {
  position: relative;
  width: 82px;
  height: 124px;
}

.discard-pile .uno-card {
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s;
}


.pass-button {
  background: linear-gradient(135deg, #4a5568, #2d3748);
  color: #fff;
  border: 2px solid #a0aec0;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  animation: パス点滅 1s infinite alternate;
}

@keyframes パス点滅 {
  from {
    transform: scale(1);
    border-color: #cbd5e0;
  }

  to {
    transform: scale(1.04);
    border-color: #fff;
  }
}


/* ==========================================================================
   チャット機能（履歴表示対応版）
   ========================================================================== */
.chat-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-btn:active {
  transform: scale(0.95);
  background: rgba(255, 204, 0, 0.3);
}

/* --- モーダル共通オーバーレイ（3つのモーダルを1つに統合） --- */
.modal-overlay,
.color-modal-overlay,
.chat-modal-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  justify-content: center;
  align-items: center;
  z-index: 500;
  padding: 16px;
}

/* 色選択時だけ手札スクロール用に下を空けてタッチ透過 */
.color-modal-overlay {
  bottom: 175px;
  pointer-events: none;
}

.color-modal-dialog {
  pointer-events: auto;
}

/* チャットモーダル（下部175pxを開けて手札を見えるようにする！） */
.chat-modal-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 175px !important;
  /* 下の手札エリアを完全開放！ */
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: flex-start;
  padding-top: 10px;
  z-index: 600;

}

.chat-modal-dialog {
  pointer-events: auto;
  width: 100%;
  /* 画面幅に合わせて可変 */
  /* チャットダイアログ内だけタップ可能 */
}


.chat-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: bold;
  color: #ffcc00;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-close-btn {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

/* 履歴リスト枠（縦スクロール） */
.chat-history-list {
  flex: 1;
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.chat-empty-hint {
  color: #777;
  font-size: 12px;
  text-align: center;
  margin-top: 30px;
}

.chat-history-item {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-all;
}

.chat-history-item.my-chat {
  background: rgba(255, 204, 0, 0.18);
  border-left: 3px solid #ffcc00;
}

.chat-user {
  font-weight: bold;
  color: #ffcc00;
  margin-right: 4px;
}

.chat-history-item.my-chat .chat-user {
  color: #68d391;
}

/* 入力バー */
.chat-input-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 20px;
  padding: 4px 6px 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-input-text {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.chat-send-btn {
  background: linear-gradient(135deg, #ffaa00, #ff5500);
  border: none;
  border-radius: 16px;
  color: #fff;
  font-weight: bold;
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
}

/* ==========================================================================
   TikTokライブ風：画面左側のコメント・スタンプ表示
   ========================================================================== */
.chat-overlay-container {
  position: absolute;
  top: 36%;
  /* 中央テーブルの横あたり */
  left: 14px;
  /* 画面左端から14px */
  transform: none;
  /* 中央揃えを解除！ */
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  /* 左寄せ！ */
  pointer-events: none;
  z-index: 700;
  max-width: 200px;
}

/* 吹き出しのコンパクト化 */
.chat-bubble {
  background: rgba(10, 10, 10, 0.88);
  border: 1.5px solid #ffcc00;
  border-radius: 14px;
  padding: 6px 12px;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: コメント浮遊 2.8s forwards ease-out;
  text-align: left;
}

.chat-bubble .sender-tag {
  color: #ffcc00;
  font-size: 12px;
  margin-right: 6px;
  display: inline-block;
}

@keyframes コメント浮遊 {
  0% {
    transform: scale(0.7) translateY(20px);
    opacity: 0;
  }

  12% {
    transform: scale(1.05) translateY(0);
    opacity: 1;
  }

  20% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }

  75% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }

  100% {
    transform: scale(0.9) translateY(-30px);
    opacity: 0;
  }
}

/* --- スタンプトレイ（横スクロール） --- */
.stamp-tray {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.stamp-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.stamp-btn:active {
  transform: scale(0.9);
}

.stamp-btn.emoji {
  font-size: 24px;
}

.stamp-btn.img img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* --- 画面中央にポップアップする巨大スタンプ演出 --- */
.chat-bubble.stamp-bubble {
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* スタンプのサイズを小さめに調整（ここでお好みのサイズに変更可能！） */
.stamp-emoji-large {
  font-size: 38px;
  /* 絵文字サイズ：38px */
  line-height: 1.1;
}

.stamp-img-large {
  width: 55px;
  /* いらすとや画像： 55px */
  height: 55px;
  object-fit: contain;
  display: block;
}

/* 履歴内のスタンプ表示サイズ */
.chat-history-item .history-stamp-img {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  object-fit: contain;
}


/* --- 相手の手札丸見えデバッグ用ミニカード --- */
.spectate-mini-card {
  width: 22px;
  height: 30px;
  border-radius: 4px;
  border: 1.5px solid #ffffff;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: -6px;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}

.spectate-mini-card:first-child {
  margin-left: 0;
}

.spectate-mini-card.red {
  background: var(--uno-赤);
  color: #fff;
}

.spectate-mini-card.blue {
  background: var(--uno-青);
  color: #fff;
}

.spectate-mini-card.green {
  background: var(--uno-緑);
  color: #fff;
}

.spectate-mini-card.yellow {
  background: var(--uno-黄);
  color: #111;
}

.spectate-mini-card.wild {
  background: var(--uno-黒);
  color: #fff;
}

/* 重ね出しモーダル内のカード選択トグル */
.combo-card-selector {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.combo-card-item {
  width: 44px;
  height: 64px;
  border-radius: 6px;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.combo-card-item.excluded {
  opacity: 0.35;
  filter: grayscale(80%);
  transform: scale(0.9);
  border-style: dashed;
}

.combo-card-item .badge-keep {
  position: absolute;
  top: -7px;
  background: #222;
  color: #ffaa00;
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid #ffaa00;
  display: none;
}

.combo-card-item.excluded .badge-keep {
  display: block;
}