/* =========================================================
   對戰桌共用樣式（單人對電腦、四人麻將共用）
   選單畫面、手牌、動作按鈕、喊牌大字、結算畫面…
   以及 1 對 1 的牌桌版面（.table / .seat / .river）
   ========================================================= */

/* ---------------- 選單畫面 ---------------- */
.setup { padding-bottom: 40px; }
.variant-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}
@media (min-width: 640px) {
  .variant-list { grid-template-columns: 1fr 1fr; }
}
.variant-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.variant-card:active { transform: scale(0.98); }
.variant-card[aria-pressed="true"] {
  border-color: var(--gold);
  background: rgba(244, 201, 93, 0.14);
  box-shadow: 0 0 0 4px rgba(244, 201, 93, 0.15);
}
.v-num {
  flex: none;
  width: 64px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(160deg, #fffdf4, #f0e4c4);
  color: #b8261a;
  font-size: 32px;
  font-weight: 900;
  font-family: "Noto Serif TC", "PMingLiU", serif;
  box-shadow: 3px 3px 0 #bfa972, 5px 5px 0 #2f6b4c;
}
.v-num small { font-size: 14px; color: #1c2b5a; margin-left: 2px; }
.v-body { display: flex; flex-direction: column; gap: 4px; }
.v-body b { font-size: 18px; }
.v-body > span { font-size: 13px; color: var(--text-dim); }
.v-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.v-tags i {
  font-style: normal;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}

.options {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
}
.opt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.opt-row[hidden] { display: none; }
.opt-label { width: 72px; font-weight: 600; }
.opt-note { width: 100%; padding-left: 84px; color: var(--text-dim); font-size: 12px; }
.seg {
  display: inline-flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.seg button {
  border: 0;
  padding: 7px 12px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid rgba(255, 255, 255, 0.2); }
.seg button[aria-pressed="true"] { background: var(--gold); color: #3a2a00; font-weight: 700; }

.record {
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}
.btn-big {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  border-radius: 14px;
}

/* ---------------- 對局畫面 ---------------- */
#game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  --small-w: 26px;
  --small-h: 35px;
}
#game[hidden] { display: none; }
.game-top { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
.link-btn {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
}
.round-info { font-weight: 700; color: var(--gold); }
.icon-btn {
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.table {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
}

/* 小牌：牌河、副露、花牌、結算畫面 */
.river, .melds, .flowers, .result-hand {
  --tile-w: var(--small-w, 26px);
  --tile-h: var(--small-h, 35px);
}

.seat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
  border: 2px solid transparent;
  transition: border-color 0.3s;
}
.seat.active { border-color: rgba(244, 201, 93, 0.7); }
.seat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.avatar { font-size: 20px; }
.wind {
  padding: 1px 7px;
  border-radius: 6px;
  background: #fffaf0;
  color: #1c2b5a;
  font-weight: 800;
  font-family: "Noto Serif TC", "PMingLiU", serif;
}
.dealer {
  padding: 1px 7px;
  border-radius: 6px;
  background: #c0281c;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.dealer[hidden] { display: none; }
.pts { margin-left: auto; color: var(--text-dim); }
.pts b { color: var(--gold); font-variant-numeric: tabular-nums; }

.hand-backs { display: flex; gap: 1px; justify-content: center; min-height: 20px; }
.hand-backs .mj-tile.drawn { margin-left: 6px; }
.meld-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 4px; }
.melds, .flowers { display: flex; flex-wrap: wrap; gap: 6px; }
.flowers { gap: 1px; }
.meld { display: inline-flex; gap: 1px; }
.meld .claimed { filter: sepia(0.35) brightness(0.95); }

.river {
  flex: 1 1 auto;
  min-height: calc(var(--small-h) * 2 + 12px);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 2px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}
.river .mj-tile.last {
  outline: 2px solid #ffd54a;
  outline-offset: 1px;
  animation: last-pulse 1s ease-in-out infinite alternate;
}
@keyframes last-pulse {
  to { outline-color: rgba(255, 213, 74, 0.2); }
}

.center-info {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 13px;
  color: var(--text-dim);
}
#turn-info { color: var(--gold); font-weight: 700; }

/* ---------------- 下方：手牌與按鈕 ---------------- */
.bottom-panel {
  background: rgba(0, 0, 0, 0.28);
  padding-bottom: env(safe-area-inset-bottom);
}
.assist {
  min-height: 24px;
  padding: 4px 10px 0;
  font-size: 13px;
  text-align: center;
  color: var(--text-dim);
}
.chip {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fffaf0;
  color: #1c2b5a;
  font-weight: 700;
}
.chip i { font-style: normal; font-weight: 400; font-size: 11px; color: #888; margin-left: 3px; }
.chip.none { opacity: 0.45; text-decoration: line-through; }

.hand-wrap { padding: 0 6px; }
.hand {
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 18px 0 6px;
}
.hand .mj-tile {
  flex: none;
  cursor: pointer;
  border-radius: 5px;
  box-shadow: 1px 1px 0 #d2c08f, 2px 2px 0 #2f6b4c, 2px 4px 5px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.hand .mj-tile.drawn {
  outline: 2px solid #ffd54a;
  outline-offset: 1px;
}
.hand .mj-tile.selected {
  transform: translateY(-14px) scale(1.1);
  background: linear-gradient(160deg, #fff6b0, #ffd95a);
  z-index: 2;
}
.hand .mj-tile.tenpai-mark::after {
  content: '聽';
  position: absolute;
  top: -8px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #e0435c;
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  font-weight: 700;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 6px 8px 10px;
}
.act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.act:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.act:disabled { opacity: 0.4; cursor: default; }
.act-discard { background: var(--gold); color: #3a2a00; min-width: 110px; justify-content: center; }
.act-win { background: linear-gradient(180deg, #ff5a4e, #c0281c); animation: win-pulse 0.8s ease-in-out infinite alternate; }
.act-kong { background: linear-gradient(180deg, #a35fd6, #6f3aa0); }
.act-pon { background: linear-gradient(180deg, #3f7fd8, #1d4f9a); }
.act-chi { background: linear-gradient(180deg, #2fa35e, #1b7a3d); }
.act-pass { background: #6b7a72; }
.act .mini { display: inline-flex; gap: 1px; --tile-w: 18px; --tile-h: 24px; }
.act-wait { color: var(--text-dim); font-size: 14px; }
@keyframes win-pulse {
  to { box-shadow: 0 0 0 6px rgba(255, 90, 78, 0.35), 0 3px 0 rgba(0, 0, 0, 0.3); }
}

/* ---------------- 喊牌大字 ---------------- */
.announce {
  position: fixed;
  left: 50%;
  z-index: 150500;
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: 900;
  font-family: "Noto Serif TC", "PMingLiU", serif;
  color: #ffe27a;
  -webkit-text-stroke: 2px #7a1e12;
  text-shadow: 0 4px 0 #7a1e12, 0 0 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}
.announce.ai { top: 26%; }
.announce.me { top: 58%; }
.announce.show { animation: announce-pop 1.1s ease-out forwards; }
@keyframes announce-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(0.95); }
  28% { transform: translate(-50%, -50%) scale(1.05); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* 對局中的提示訊息放在牌桌中間，避免擋到手牌和電腦的牌 */
#game ~ .toast { top: 42%; bottom: auto; }

/* ---------------- 結算畫面 ---------------- */
.modal-box .how { font-weight: 700; color: #c0281c; }
.hand-label { margin: 8px 0 4px !important; font-size: 13px; color: #888 !important; text-align: left; }
.result-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  --small-w: 22px;
  --small-h: 29px;
}
.result-hand .win-tile { outline: 2px solid #e0435c; outline-offset: 1px; }
.score-line { font-size: 15px; }
.score-line b { color: #1b5e3a; }
.modal-box { max-height: 90vh; overflow-y: auto; }

/* 手機橫放：畫面比較矮，壓縮上方區域 */
@media (orientation: landscape) and (max-height: 500px) {
  /* 改成左右兩欄：左邊電腦、右邊你 */
  .table {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "aiseat meseat" "airiver meriver" "info info";
    gap: 4px 8px;
  }
  #ai-seat { grid-area: aiseat; }
  #me-seat { grid-area: meseat; }
  #ai-river { grid-area: airiver; }
  #me-river { grid-area: meriver; }
  .center-info { grid-area: info; }
  #me-seat .meld-row { order: 2; }
  .center-info { display: none; } /* 橫放時牌牆張數改看上方標題列 */
  .seat { padding: 3px 8px; }
  .river { min-height: calc(var(--small-h) + 10px); }
  .hand { padding-top: 14px; }
  .action-bar { min-height: 48px; padding-bottom: 6px; }
  .act { padding: 7px 16px; font-size: 16px; }
  .announce { font-size: 48px; }
}
