/* 新接龍：版面。顏色用 share.css 的變數，牌桌與牌面另有固定色（深色模式只調暗牌桌）。 */
:root {
  --fc-felt: #2f7a4b;
  --fc-felt-2: #276a40;
  --fc-slot: rgba(255, 255, 255, 0.32);
  --fc-face: #ffffff;
  --fc-edge: #b9b2a4;
  --fc-red: #c92a2a;
  --fc-black: #1f1d1a;
  --fc-sel: #ffd43b;
  --fc-ok: #74c0fc;
  --fc-ok-bg: rgba(116, 192, 252, 0.18);
  --fc-gap: 3px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fc-felt: #1f4f33;
    --fc-felt-2: #19422a;
    --fc-slot: rgba(255, 255, 255, 0.22);
    --fc-face: #f1ece2;
    --fc-edge: #8c8576;
  }
}

/* 頁首與頂列收緊一點，把高度留給牌桌 */
.jt-header { padding: 6px 0; margin-bottom: 8px; }
.fc-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; }
.fc-bar .fc-deal {
  appearance: none; border: 1px solid var(--jt-line); background: var(--jt-surface); color: var(--jt-text);
  font: inherit; font-weight: 700; min-height: 44px; padding: 6px 12px; border-radius: 12px; cursor: pointer;
}
.fc-bar .fc-meta { margin-left: auto; display: flex; gap: 12px; color: var(--jt-muted); font-variant-numeric: tabular-nums; }
.fc-bar .fc-meta b { color: var(--jt-text); font-weight: 700; }

/* 牌桌：比內容區左右各寬 12px，讓 360px 的手機每欄多幾像素 */
.fc-board {
  margin: 0 -12px; padding: 8px 6px 10px; border-radius: 14px;
  background: linear-gradient(180deg, var(--fc-felt), var(--fc-felt-2));
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.fc-top, .fc-tab { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--fc-gap); }
.fc-top { margin-bottom: 8px; }
.fc-tab { position: relative; }

.fc-slot {
  position: relative; aspect-ratio: 5 / 7; border-radius: 6px; border: 1.5px dashed var(--fc-slot); cursor: pointer;
}
.fc-found { border-style: solid; }
.fc-slot > .fc-card { position: absolute; inset: -1.5px; width: auto; }
.fc-ghost {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 6vw, 30px); opacity: 0.45; filter: grayscale(0.2);
}
.fc-ghost.fc-red { color: #ffc9c9; }
.fc-ghost.fc-black { color: #e9ecef; }

.fc-col { position: relative; min-height: 100%; cursor: pointer; }
.fc-col:empty::before {
  content: ''; display: block; aspect-ratio: 5 / 7; border-radius: 6px; border: 1.5px dashed var(--fc-slot);
}

/* 牌面：角標大字（點數加花色），露出的那一截就認得出來 */
.fc-card {
  position: absolute; left: 0; width: 100%; aspect-ratio: 5 / 7; border-radius: 6px;
  background: var(--fc-face); border: 1px solid var(--fc-edge); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  overflow: hidden; line-height: 1;
}
.fc-red { color: var(--fc-red); }
.fc-black { color: var(--fc-black); }
.fc-corner {
  position: absolute; top: 3px; left: 3px; right: 2px; display: flex; align-items: baseline; gap: 1px;
  font-size: clamp(13px, 3.9vw, 19px); white-space: nowrap; letter-spacing: -0.5px;
}
.fc-corner b { font-weight: 800; }
.fc-pip { position: absolute; right: 8%; bottom: 6%; font-size: clamp(20px, 7vw, 36px); }
.fc-col > .fc-card:not(:last-child) .fc-pip { display: none; }
.fc-sel { box-shadow: 0 0 0 2.5px var(--fc-sel), 0 2px 6px rgba(0, 0, 0, 0.35); background: #fff8db; z-index: 2; }

/* 選好牌之後，放得下的地方發光（藍色，和黃色的選取分開） */
.fc-col.fc-ok > .fc-card:last-child { box-shadow: 0 0 0 2.5px var(--fc-ok), 0 0 12px var(--fc-ok); }
.fc-col.fc-ok:empty::before, .fc-slot.fc-ok { border: 2px solid var(--fc-ok); background: var(--fc-ok-bg); box-shadow: 0 0 10px var(--fc-ok); }
.fc-slot.fc-ok > .fc-card:last-child { box-shadow: 0 0 0 2.5px var(--fc-ok); }
.fc-ok { animation: fc-glow 1.2s ease-in-out infinite alternate; }
@keyframes fc-glow { from { filter: brightness(1); } to { filter: brightness(1.12); } }

/* 搬牌動畫（FLIP）：飛行中的牌浮在最上面 */
.fc-flying { box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35); will-change: transform; }
/* 放錯地方：搖一搖 */
.fc-shake { animation: fc-shake 0.36s ease-in-out; }
@keyframes fc-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
/* 過關：回收堆的 K 依序跳起來，撒彩色紙片 */
.fc-party .fc-found > .fc-card:last-child { animation: fc-hop 0.5s ease-out 2; }
.fc-party .fc-found:nth-child(6) > .fc-card:last-child { animation-delay: 0.12s; }
.fc-party .fc-found:nth-child(7) > .fc-card:last-child { animation-delay: 0.24s; }
.fc-party .fc-found:nth-child(8) > .fc-card:last-child { animation-delay: 0.36s; }
@keyframes fc-hop { 0%, 100% { transform: none; } 40% { transform: translateY(-14px) rotate(-6deg); } 70% { transform: translateY(-4px) rotate(3deg); } }
.fc-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 15; }
.fc-confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fc-fall 1.4s linear forwards; }
@keyframes fc-fall { to { top: 105%; transform: rotate(540deg) translateX(30px); } }

.fc-status { margin: 8px 0 0; color: var(--jt-muted); font-size: 14px; min-height: 2.8em; }
.fc-finish { display: block; width: 100%; margin-top: 10px; font-size: 17px; }
.fc-finish[hidden], .fc-status[hidden] { display: none; }
.fc-done-bar { display: flex; gap: 8px; align-items: center; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--jt-surface); border: 1px solid var(--jt-line); }
.fc-done-bar[hidden] { display: none; }
.fc-done-bar span { flex: 1; font-weight: 700; }

/* 底部工具列：黏在畫面下緣，單手好按 */
.fc-tools {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: var(--jt-bg);
}
.fc-tools .jt-btn { flex: 1; padding: 8px 6px; }
.fc-tools .jt-btn:disabled { opacity: 0.45; cursor: default; }
/* 提示訊息浮在工具列上面，不要蓋住按鈕 */
.jt-toast { bottom: calc(76px + env(safe-area-inset-bottom)); }

/* 彈窗 */
.fc-overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center; padding: 12px;
}
.fc-overlay[hidden] { display: none; }
.fc-sheet {
  position: relative; width: 100%; max-width: 480px; max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--jt-surface); color: var(--jt-text); border-radius: 18px; padding: 20px 16px 16px;
}
@media (min-height: 640px) { .fc-overlay { align-items: center; } }
.fc-x {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; background: none;
  color: var(--jt-muted); font-size: 26px; cursor: pointer;
}
.fc-h { margin: 0 40px 12px 0; font-size: 20px; }
.fc-big { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.fc-win { font-size: 46px; text-align: center; line-height: 1.2; }
.fc-win + .fc-h { text-align: center; margin-right: 0; }
.fc-win ~ .fc-big, .fc-win ~ .fc-note, .fc-win ~ .fc-badges { text-align: center; }
.fc-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 0 0 8px; }
.fc-badges span { background: var(--jt-accent); color: var(--jt-accent-text); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 700; }
.fc-note { color: var(--jt-muted); font-size: 14px; margin: 8px 0; }
.fc-warn { background: rgba(232, 89, 12, 0.12); border-radius: 10px; padding: 8px 10px; font-size: 14px; margin: 0 0 12px; }
.fc-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.fc-pick { margin-top: 16px; border-top: 1px solid var(--jt-line); padding-top: 12px; }
.fc-pick label { display: block; font-weight: 700; margin-bottom: 6px; }
.fc-pick-row { display: flex; gap: 8px; }
.fc-pick input {
  flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 18px; padding: 6px 12px; border-radius: 12px;
  border: 1px solid var(--jt-line); background: var(--jt-bg); color: var(--jt-text);
}
.fc-stats { display: grid; gap: 2px; }
.fc-stat { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--jt-line); }
.fc-stat b { text-align: right; }
