*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #1e2749;
  --accent: #9B59B6;
  --text: #e0e0e0;
  --text-muted: #c0c0c0;
  --border: #2a2a4a;
  --win: #f4d03f;
  --lose: #e74c3c;
  --info: #aed6f1;
}

body {
  background: var(--bg);
  background-image: url('/draw-poker/bg.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  min-height: 100vh;
  padding-bottom: 0;
}

/* ─── キャラクター固定オーバーレイ（左下） ─────────────────── */
.character-overlay {
  position: fixed;
  left: 0;
  bottom: 56px; /* 下バーの上 */
  width: 700px;
  pointer-events: none;
  z-index: 15;
}

.dark-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.30);
  z-index: 10;
  pointer-events: none;
}

.character-figure {
  position: relative;
  width: 700px;
}

.character-img {
  width: 100%;
  display: block;
  object-fit: contain;
  object-position: bottom center;
  animation: breathe 4s ease-in-out infinite;
  transform-origin: bottom center;
}

/* セリフバブル：キャラ画像の中央やや下にオーバーレイ */
.speech-bubble {
  position: absolute;
  bottom: 35%;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: 250px;
  background: rgba(255, 255, 255, 0.88);
  color: #1a1a2e;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  line-height: 1.55;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
}

.speech-bubble.hidden { display: none; }
.speech-bubble.show   { opacity: 1; }

/* ─── 2カラムレイアウト（ゲーム + 役一覧） ─────────────────── */
.poker-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  min-height: 100vh;
}

/* ─── ゲームパネル ──────────────────────────────────────────── */
.game-panel {
  position: relative;
  z-index: 20;
  padding: 24px 0 48px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: none;
}

.back-link {
  align-self: flex-start;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 14px;
  background: rgba(0,0,0,0.40);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.back-link:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  transform: translateY(-1px);
}

.game-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 24px;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

/* ─── 対戦相手（中央） ─────────────────────────────────────── */
.opponent-section {
  position: static;
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
}

/* ─── プレイヤーセクション ─────────────────────────────────── */
.player-section { margin-bottom: 6px; text-align: center; }

.player-label {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.1em;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 16px;
  border-radius: 999px;
  margin-bottom: 10px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.player-section-self {
  margin-top: 32px;
}

/* ─── カードエリア ─────────────────────────────────────────── */
.card-area {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
  min-height: 96px;
  align-items: flex-start;
}

.cpu-card-area {
  justify-content: center;
  min-height: 96px;
}

.card-placeholder {
  width: 100%;
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  align-self: center;
}

/* ─── カード ────────────────────────────────────────────────── */
.card {
  position: relative;
  width: 82px;
  min-height: 114px;
  background: #fff;
  border-radius: 9px;
  border: 2px solid #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  color: #1a1a1a;
  user-select: none;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.card:hover:not(.card-back) { transform: translateY(-3px); }
.card.red { color: #c0392b; }

/* 対戦相手カードは小さく */
.cpu-card-area .card {
  width: 58px;
  min-height: 96px;
  font-size: 0.7rem;
  padding: 4px;
}

.cpu-card-area .card-center.suit { font-size: 1.1rem; }

/* 捨てるカード */
.card.discard {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231,76,60,0.4);
  transform: translateY(6px);
}
.card.discard:hover { transform: translateY(6px); }

/* 裏面 */
.card.card-back {
  background: #1a3a6e;
  border-color: #2a4a8e;
  cursor: default;
  justify-content: center;
}

.card-back-inner {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.18);
  background: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,0.06) 0px, rgba(255,255,255,0.06) 2px,
    transparent 2px, transparent 8px
  );
}

.card-top,
.card-bottom {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.card-bottom { transform: rotate(180deg); }
.card-center.suit { font-size: 1.5rem; line-height: 1; }

/* 捨てバッジ */
.discard-badge {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: #e74c3c;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* ─── 手役表示 ───────────────────────────────────────────────── */
.hand-result {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 22px;
  margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.hand-result.win  { color: var(--win); }
.hand-result.lose { color: var(--lose); }
.hand-result.info { color: var(--info); }

/* ─── アクションバー ─────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ─── ボタン ─────────────────────────────────────────────────── */
.btn {
  padding: 11px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--accent);  color: #fff; }
.btn-danger  { background: var(--lose);   color: #fff; }

.hidden { display: none !important; }

/* ─── 役一覧パネル（右） ────────────────────────────────────── */
.payout-panel {
  position: relative;
  z-index: 20;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 24px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.payout-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.payout-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.payout-table th,
.payout-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.payout-table th {
  color: var(--text);
  font-weight: 600;
}

.payout-table td:last-child {
  text-align: right;
  font-weight: 600;
}

.payout-note {
  margin-top: 10px;
  font-size: 0.67rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── トップバー（ゲーム一覧 + コイン） ─────────────────────── */
.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  margin-bottom: 16px;
}

.top-coin {
  display: flex;
  align-items: center;
  gap: 6px;
}

.coin-label { font-size: 0.85rem; color: var(--text-muted); }
.coin-value { font-size: 1.1rem; font-weight: 700; color: #f1c40f; }

/* ─── BETモーダル ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 200px;
  z-index: 300;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 32px;
  width: 320px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.modal-coins {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
}

.modal-coins strong {
  color: #f1c40f;
}

.bet-input-large {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.5rem;
  text-align: center;
  font-family: inherit;
}
.bet-input-large:focus {
  outline: none;
  border-color: var(--accent);
}

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

.modal-actions .btn {
  flex: 1;
}

/* ─── キャラクター呼吸アニメーション ────────────────────────── */
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.018); }
}

/* ─── カードアニメーション ───────────────────────────────────── */
@keyframes card-in {
  from { opacity: 0; transform: translateY(-14px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

@keyframes card-flip {
  0%   { transform: scaleX(0.05); opacity: 0.3; }
  45%  { transform: scaleX(0.05); opacity: 0.3; }
  100% { transform: scaleX(1);    opacity: 1;   }
}

.card.animate-in {
  animation: card-in 0.22s ease both;
}

.card.animate-flip {
  animation: card-flip 0.28s ease both;
}

/* デスクトップではモバイルキャラエリアを非表示 */
.mobile-chara-area { display: none; }

/* ─── モバイル（≤700px） ─────────────────────────────────────── */
@media (max-width: 700px) {
  .character-overlay { display: none; }

  .modal-overlay { padding-right: 0; }

  .mobile-chara-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 8px;
  }

  .mobile-chara-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
  }

  .mobile-chara-bubble {
    flex: 1;
    background: rgba(255,255,255,0.88);
    color: #1a1a2e;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.82rem;
    line-height: 1.55;
    text-align: center;
    opacity: 0;
    transition: opacity 0.35s;
  }

  .mobile-chara-bubble.show   { opacity: 1; }
  .mobile-chara-bubble.hidden { display: none; }

  .poker-layout {
    grid-template-columns: 1fr;
    padding-left: 0;
  }

  .opponent-section {
    position: static;
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
  }

  .cpu-card-area {
    justify-content: center;
  }

  .payout-panel {
    position: static;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 16px;
  }

  .game-panel {
    padding: 14px 12px 24px;
  }

  .card {
    width: 62px;
    min-height: 88px;
    padding: 4px;
  }

  .card-top, .card-bottom { font-size: 0.7rem; }
  .card-center.suit       { font-size: 1.1rem; }
}
