/* =========================================================
   麻將翻牌頁面樣式
   ========================================================= */
.sol-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 手機瀏覽器網址列會伸縮，用 dvh 比較準 */
  overflow: hidden;
}

/* ---------- 上方狀態列 ---------- */
.sol-topbar { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
.sol-stats {
  display: flex;
  gap: 16px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}
.stat small {
  font-size: 11px;
  color: var(--text-dim);
}
.stat b {
  font-size: 17px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.icon-btn {
  appearance: none;
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- 牌桌 ---------- */
#board-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#board {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
}

.sol-tile {
  position: absolute;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; /* iPhone 長按不要跳出選單 */
  transition: opacity 0.18s, transform 0.18s, filter 0.2s;
}
/* 被擋住、不能點的牌：稍微變暗 */
.sol-tile.blocked {
  filter: brightness(0.7) saturate(0.8);
  cursor: default;
}
/* 選取中 */
.sol-tile.selected {
  background: linear-gradient(160deg, #fff6b0 0%, #ffd95a 100%);
  border-color: #e0a800;
  transform: translateY(-4px);
  filter: drop-shadow(0 0 6px rgba(255, 215, 80, 0.9));
}
/* 提示閃爍 */
.sol-tile.hint { animation: hint-blink 0.5s ease-in-out 4; }
@keyframes hint-blink {
  50% { background: #9be7ff; border-color: #2aa7d6; filter: drop-shadow(0 0 8px #6fd3ff); }
}
/* 點到被擋住的牌時抖一下 */
.sol-tile.shake { animation: shake 0.3s; }
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
/* 偷看：這張牌變透明並往旁邊挪開 */
.sol-tile.peeking {
  opacity: 0.12;
  transform: translate(14px, -18px) rotate(6deg);
  pointer-events: none;
}
/* 消除：亮一下、放大、再縮小消失 */
.sol-tile.removed {
  animation: tile-out 0.38s ease-in forwards;
  pointer-events: none;
}
@keyframes tile-out {
  0% { filter: brightness(1.4) drop-shadow(0 0 10px #ffe27a); }
  35% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(0.3); opacity: 0; visibility: hidden; }
}
/* 讀檔時已經消除的牌直接不顯示 */
.sol-tile.gone { display: none; }
/* 洗牌：翻轉一圈 */
.sol-tile.flipping { animation: flip 0.4s ease-in-out; }
@keyframes flip {
  50% { transform: scaleX(0); }
}

/* 消除時飄出的分數 */
.float-score {
  position: absolute;
  z-index: 99999;
  transform: translate(-50%, -50%);
  font-size: 30px;
  font-weight: 800;
  color: #ffe27a;
  text-align: center;
  text-shadow: 0 2px 0 #7a4b00, 0 0 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  white-space: nowrap;
  animation: float-up 1s ease-out forwards;
}
.float-score small {
  display: block;
  font-size: 18px;
  color: #ffb3c1;
}
@keyframes float-up {
  0% { opacity: 0; margin-top: 10px; }
  15% { opacity: 1; }
  100% { opacity: 0; margin-top: -60px; }
}

/* Combo 標籤 */
.combo-pill {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  padding: 4px 14px 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e0435c, #f08a24);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  pointer-events: none;
}
.combo-pill[hidden] { display: none; }
.combo-pill.run { animation: combo-pop 0.3s ease-out; }
.combo-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: #fff;
  transform-origin: left;
}
.combo-pill.run .combo-bar { animation: combo-time 5s linear forwards; }
@keyframes combo-pop {
  0% { transform: translateX(-50%) scale(0.6); }
  60% { transform: translateX(-50%) scale(1.15); }
}
@keyframes combo-time {
  to { transform: scaleX(0); }
}

/* ---------- 下方按鈕列 ---------- */
.sol-toolbar {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.25);
}
.tool {
  position: relative;
  flex: 1;
  max-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tool .ico { font-size: 20px; line-height: 1.1; }
.tool:active { background: rgba(255, 255, 255, 0.22); }
.tool:disabled { opacity: 0.4; cursor: default; }
.tool .count {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--gold);
  color: #3a2a00;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.tool.used-up .count { background: #777; color: #eee; }

/* 小螢幕手機：狀態列縮小一點 */
@media (max-width: 360px) {
  .sol-stats { gap: 10px; }
  .stat b { font-size: 15px; }
  .back-link { font-size: 14px; }
}
