/* ============================================================================
   記憶翻牌 — Memory Match  ·  Visual redesign (drop-in stylesheet)
   ----------------------------------------------------------------------------
   保留你現有的 HTML 結構與 class 名稱，只換 CSS。

   ▼ 我假設的「狀態 class / 屬性」名稱（若你的 JS 用別的名字，改這裡即可）：
     • 玩家人數選中    .seg button.active   （也支援 .selected / [aria-pressed="true"]）
     • 牌已翻開        .card.flipped        （也支援 .is-flipped / .open）
     • 配對成功        .card.matched
     • 目前輪到的玩家  .turn-indicator[data-player="1..4"]
     • 計分板高亮      .score-chip.active   （也支援 .current）
     • 結算畫面容器    .end-card            （也支援沿用 .start-card）
     • 勝者那一列      .end-row.winner      （也支援 .win）

   ▼ 牌面建議結構（face-front 內，做出「角落小數字+花色 / 中央大花色」）：
     <div class="face-front" data-suit="♥">
       <span class="rank">7</span>
       <span class="pip">♥</span>
     </div>
     未改 JS 也能用：face-front 內若只有純數字，會置中放大；
     用上面的結構則會得到完整撲克牌排版。紅花 ♥♦ 自動轉紅、♠♣ 轉黑。
   ============================================================================ */

/* ----------------------------------------------------------------- Tokens -- */
:root {
  /* 玩家代表色 */
  --p1: #e5484d;   /* 紅 */
  --p2: #3a6df0;   /* 藍 */
  --p3: #2faa6a;   /* 綠 */
  --p4: #9b5de5;   /* 紫 */

  /* 金色（主按鈕 / 牌背描金 / 勝者） */
  --gold-1: #ffe08a;
  --gold-2: #f4c44b;
  --gold-3: #d99a2b;
  --gold-ink: #5b3d05;

  /* 中性 / 玻璃 */
  --ink: #1c2530;
  --ink-soft: #5b6675;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-line: rgba(255, 255, 255, 0.55);
  --hairline: rgba(20, 30, 40, 0.08);

  /* 陰影 */
  --shadow-card: 0 18px 40px -18px rgba(8, 30, 22, 0.55), 0 4px 14px -6px rgba(8, 30, 22, 0.35);
  --shadow-pop:  0 26px 60px -22px rgba(8, 30, 22, 0.6);

  --radius: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
          "Microsoft JhengHei", "Noto Sans TC", Roboto, system-ui, sans-serif;
  --font-card: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
               "Songti TC", serif;
}

/* ------------------------------------------------------------- Base / felt -- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* 高級牌桌絨布：柔和漸層 + 暈影 + 細緻織紋 */
  background-color: #14704f;
  background-image:
    radial-gradient(120% 90% at 50% -10%, #2fae7d 0%, #1c8a60 38%, #126047 72%, #0c4936 100%),
    radial-gradient(80% 60% at 50% 120%, rgba(0,0,0,0.28), transparent 60%);
  background-attachment: fixed;
  position: relative;
}
/* 牌桌絨布織紋（極淡斜紋，增加質感而不搶眼） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.022) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.035) 0 2px, transparent 2px 5px);
  mix-blend-mode: soft-light;
  z-index: 0;
}

/* =====================================================  START / END card  == */
.start-card,
.end-card {
  position: relative;
  z-index: 1;
  width: min(440px, calc(100vw - 40px));
  margin: auto;
  padding: 32px 30px 30px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.9));
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-line);
  box-shadow:
    0 30px 70px -28px rgba(6, 28, 20, 0.7),
    0 2px 0 rgba(255,255,255,0.7) inset,
    0 -1px 0 rgba(0,0,0,0.03) inset;
  animation: cardRise 0.6s var(--ease) both;
}

.start-card h1,
.end-card h2 {
  margin: 0 0 6px;
  text-align: center;
  font-size: clamp(26px, 4.6vw, 34px);
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--ink);
}
.start-card h1 img,
.start-card h1 svg { vertical-align: -4px; }

.start-card .subtitle,
.start-card p {
  margin: 0 0 26px;
  text-align: center;
  font-size: 15px;
  color: var(--ink-soft);
}

/* 區段小標題（玩家人數） */
.start-card > label,
.seg-label,
.start-card .label {
  display: block;
  margin: 0 2px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  text-transform: none;
}

/* ----------------------------------------------------- segmented control -- */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-bottom: 26px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(20, 30, 40, 0.05);
  border: 1px solid var(--hairline);
}
.seg button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  cursor: pointer;
  min-height: 46px;
  padding: 0 8px;
  border-radius: 11px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  background: transparent;
  transition: transform 0.18s var(--ease), background 0.2s, color 0.2s, box-shadow 0.2s;
}
.seg button:hover { color: var(--ink); background: rgba(255,255,255,0.7); }
.seg button:active { transform: scale(0.96); }
.seg button.active,
.seg button.selected,
.seg button[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(180deg, #34c285, #1f9c66);
  box-shadow:
    0 8px 18px -8px rgba(20, 140, 90, 0.8),
    0 1px 0 rgba(255,255,255,0.4) inset;
}

/* -------------------------------------------------------- primary button -- */
.btn-primary {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  min-height: 56px;
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 52%, var(--gold-3) 100%);
  box-shadow:
    0 14px 26px -12px rgba(190, 130, 20, 0.85),
    0 2px 0 rgba(255,255,255,0.55) inset,
    0 -2px 0 rgba(150, 100, 10, 0.25) inset;
  transition: transform 0.16s var(--ease), box-shadow 0.2s, filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 18px 32px -12px rgba(190,130,20,0.95), 0 2px 0 rgba(255,255,255,0.6) inset; }
.btn-primary:active { transform: translateY(2px) scale(0.99); box-shadow: 0 8px 16px -10px rgba(190,130,20,0.9), 0 2px 0 rgba(255,255,255,0.45) inset; }

/* 結算畫面：回到主畫面（次要連結） */
.end-card .link,
.end-card a,
.btn-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 8px;
  text-align: center;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s;
}
.end-card .link:hover,
.end-card a:hover,
.btn-link:hover { color: var(--ink); }

/* ----------------------------------------------------------- end rows --- */
.end-card h2 { margin-bottom: 22px; }
.end-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(20, 30, 40, 0.045);
  border: 1px solid var(--hairline);
}
/* 玩家色點（每列第一個 ::before；亦保留你既有的圓點寫法） */
.end-row::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--row-pc, var(--p1));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--row-pc, var(--p1)) 22%, transparent);
}
.end-row:nth-child(odd of .end-row),
.end-row { --row-pc: var(--p1); }
.end-row.p2,  .end-row:nth-of-type(2) { --row-pc: var(--p2); }
.end-row.p3,  .end-row:nth-of-type(3) { --row-pc: var(--p3); }
.end-row.p4,  .end-row:nth-of-type(4) { --row-pc: var(--p4); }
/* 對數 / 名次推到右側 */
.end-row > :last-child { margin-left: auto; }

/* 勝者列 — 金色高亮 + 微光掃過 */
.end-row.winner,
.end-row.win,
.end-row.is-winner {
  color: var(--gold-ink);
  background: linear-gradient(180deg, #fff4d2, #ffe9ad);
  border-color: rgba(217, 154, 43, 0.45);
  box-shadow: 0 10px 24px -14px rgba(190, 130, 20, 0.7);
  position: relative;
  overflow: hidden;
}
.end-row.winner::after,
.end-row.win::after,
.end-row.is-winner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255,255,255,0.65) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: shimmer 2.6s ease-in-out 0.4s infinite;
}

/* =========================================================  GAME screen  == */
/* ----------------------------------------------------------------- topbar -- */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(12px, 3vw, 22px);
}
/* 返回鍵 */
.topbar .back,
.topbar button:first-child {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; cursor: pointer;
  border-radius: 13px;
  font-size: 22px; line-height: 1;
  color: #fff;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform 0.16s var(--ease), background 0.2s;
}
.topbar .back:hover,
.topbar button:first-child:hover { background: rgba(255,255,255,0.26); }
.topbar .back:active,
.topbar button:first-child:active { transform: scale(0.92); }

/* 回合提示 — 玻璃膠囊，依玩家代表色發光 */
.turn-indicator {
  --pc: var(--p1);
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 14px;
  font-size: clamp(15px, 2.4vw, 18px);
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--pc) 88%, #000 0%),
      color-mix(in srgb, var(--pc) 70%, #000 16%));
  border: 1px solid color-mix(in srgb, #fff 35%, var(--pc));
  box-shadow:
    0 12px 26px -12px color-mix(in srgb, var(--pc) 80%, transparent),
    0 1px 0 rgba(255,255,255,0.35) inset;
  animation: turnPulse 2.4s ease-in-out infinite;
}
.turn-indicator::before {
  content: "";
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.25);
}
.turn-indicator[data-player="1"] { --pc: var(--p1); }
.turn-indicator[data-player="2"] { --pc: var(--p2); }
.turn-indicator[data-player="3"] { --pc: var(--p3); }
.turn-indicator[data-player="4"] { --pc: var(--p4); }

/* 計時 */
.timer {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 10px 14px;
  border-radius: 13px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ----------------------------------------------------------- scoreboard -- */
.scoreboard {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 4px 16px 10px;
}
.score-chip {
  --pc: var(--p1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-line);
  box-shadow: 0 8px 18px -12px rgba(0,0,0,0.5);
  transition: transform 0.2s var(--ease), box-shadow 0.25s, background 0.25s;
}
/* 玩家色點 */
.score-chip::before {
  content: "";
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--pc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 24%, transparent);
}
.score-chip:nth-child(1) { --pc: var(--p1); }
.score-chip:nth-child(2) { --pc: var(--p2); }
.score-chip:nth-child(3) { --pc: var(--p3); }
.score-chip:nth-child(4) { --pc: var(--p4); }
/* 分數數字（建議放在最後一個元素內）推開一點 */
.score-chip > :last-child {
  margin-left: 4px;
  min-width: 18px;
  padding: 1px 7px;
  border-radius: 7px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--pc) 14%, transparent);
  color: color-mix(in srgb, var(--pc) 70%, #000);
}
/* 目前輪到的玩家：放大 + 該玩家色描邊發光 */
.score-chip.active,
.score-chip.current,
.score-chip.is-active {
  transform: translateY(-2px) scale(1.05);
  background: #fff;
  box-shadow:
    0 0 0 2px var(--pc),
    0 0 0 6px color-mix(in srgb, var(--pc) 22%, transparent),
    0 12px 24px -12px color-mix(in srgb, var(--pc) 70%, transparent);
}

/* ================================================================  BOARD  == */
.board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 16px);
  width: min(880px, calc(100vw - 28px));
  margin: 6px auto 28px;
  padding: 0 2px;
  perspective: 1600px;
}
/* RWD：窄螢幕自動降到 4 / 3 欄 */
@media (max-width: 560px) { .board { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 380px) { .board { grid-template-columns: repeat(3, minmax(0,1fr)); } }

/* --------------------------------------------------------------- the card -- */
.card {
  position: relative;
  aspect-ratio: 2.5 / 3.5;
  border-radius: 14px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease);
  /* 進場：逐張發牌（用 backwards，動畫結束後才不會蓋掉 .flipped 的 rotateY） */
  animation: dealIn 0.5s var(--ease) backwards;
  -webkit-tap-highlight-color: transparent;
}
.card:hover { transform: translateY(-4px); }
.card:hover.flipped,
.card:hover.is-flipped,
.card:hover.open { transform: translateY(-4px) rotateY(180deg); }

/* 翻開 */
.card.flipped,
.card.is-flipped,
.card.open { transform: rotateY(180deg); }

/* 兩個面 */
.face-back,
.face-front {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ---- 牌背：深藍描金 + 鑽石格紋 + 中央金徽 ------------------------------- */
.face-back {
  color: rgba(255,255,255,0.9);
  background-color: #1b2a6b;
  background-image:
    /* 鑽石格紋 */
    linear-gradient(45deg, rgba(244,196,75,0.16) 25%, transparent 25% 75%, rgba(244,196,75,0.16) 75%),
    linear-gradient(45deg, rgba(244,196,75,0.16) 25%, transparent 25% 75%, rgba(244,196,75,0.16) 75%),
    /* 底色立體感 */
    radial-gradient(120% 100% at 50% 30%, #2c3f93 0%, #1b2a6b 55%, #121d52 100%);
  background-size: 20px 20px, 20px 20px, 100% 100%;
  background-position: 0 0, 10px 10px, 0 0;
}
/* 內描金框 */
.face-back::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 9px;
  border: 1.5px solid rgba(244,196,75,0.55);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25), 0 0 14px rgba(244,196,75,0.18) inset;
}
/* 中央 ? 變成優雅金徽（沿用 face-back 內的 ? 文字） */
.face-back {
  font-family: var(--font-card);
  font-size: 0; /* 隱藏原本大小，用 ::after 視覺呈現 */
}
.face-back::after {
  content: "♦";
  position: absolute;
  font-family: var(--font-card);
  font-size: clamp(20px, 5vw, 30px);
  color: var(--gold-1);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4), 0 0 12px rgba(244,196,75,0.5);
  width: clamp(40px, 9vw, 54px);
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(244,196,75,0.22), rgba(244,196,75,0.06));
  border: 1.5px solid rgba(244,196,75,0.5);
}

/* ---- 牌面：乾淨優雅撲克牌排版 ----------------------------------------- */
.face-front {
  --suit-color: #1c2530;       /* 預設黑花 */
  transform: rotateY(180deg);  /* 預先翻到背面，.card 翻轉時才露出 */
  flex-direction: column;
  color: var(--suit-color);
  background:
    radial-gradient(140% 120% at 50% 0%, #ffffff, #f6f7f9 80%);
  border: 1px solid rgba(20,30,40,0.06);
  font-family: var(--font-card);
}
/* 紅花自動轉紅（依 data-suit） */
.face-front[data-suit="♥"],
.face-front[data-suit="♦"],
.face-front.red { --suit-color: #d4233b; }

/* 未改 JS 也可用：face-front 內若只是純數字，置中放大 */
.face-front { font-size: clamp(30px, 8vw, 46px); font-weight: 700; line-height: 1; }

/* 用建議結構時的精緻排版 */
.face-front .rank {
  position: absolute;
  top: 8px; left: 9px;
  font-size: clamp(13px, 3vw, 18px);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.5px;
}
.face-front .rank::after {        /* 角落小花色（取 data-suit） */
  content: attr(data-suit);
  display: block;
  font-size: 0.78em;
}
/* 右下角鏡像重複 */
.face-front .rank:only-of-type::before { content: none; }
.face-front[data-suit]::after {
  content: attr(data-suit);
  position: absolute;
  bottom: 8px; right: 9px;
  font-size: clamp(12px, 2.6vw, 16px);
  transform: rotate(180deg);
  opacity: 0.9;
}
/* 中央大花色 */
.face-front .pip {
  font-size: clamp(34px, 9vw, 52px);
  line-height: 1;
  text-shadow: 0 2px 6px color-mix(in srgb, var(--suit-color) 30%, transparent);
}

/* ---- 配對成功：縮小消失（升級版：彈一下→旋轉縮小→金光） ------------- */
.card.matched {
  animation: matchOut 0.6s var(--ease) forwards;
  pointer-events: none;
}
.card.matched .face-front {
  box-shadow: 0 0 0 2px var(--gold-2), 0 0 26px rgba(244,196,75,0.7), var(--shadow-card);
}

/* ===============================================================  Keyframes */
@keyframes cardRise {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes dealIn {
  from { transform: translateY(-16px) rotateY(0) scale(0.88); }
  to   { transform: translateY(0) rotateY(0) scale(1); }
}
@keyframes turnPulse {
  0%, 100% { box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--pc) 80%, transparent), 0 0 0 0 color-mix(in srgb, var(--pc) 45%, transparent), 0 1px 0 rgba(255,255,255,0.35) inset; }
  50%      { box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--pc) 80%, transparent), 0 0 0 7px color-mix(in srgb, var(--pc) 0%, transparent), 0 1px 0 rgba(255,255,255,0.35) inset; }
}
@keyframes matchOut {
  0%   { transform: rotateY(180deg) scale(1); opacity: 1; }
  28%  { transform: rotateY(180deg) scale(1.12); }
  100% { transform: rotateY(180deg) scale(0) rotate(8deg); opacity: 0; }
}
@keyframes shimmer {
  0%   { transform: translateX(-120%); }
  60%, 100% { transform: translateX(120%); }
}

/* 逐張發牌延遲（前 24 張） */
.card:nth-child(1){animation-delay:.02s}.card:nth-child(2){animation-delay:.05s}
.card:nth-child(3){animation-delay:.08s}.card:nth-child(4){animation-delay:.11s}
.card:nth-child(5){animation-delay:.14s}.card:nth-child(6){animation-delay:.17s}
.card:nth-child(7){animation-delay:.20s}.card:nth-child(8){animation-delay:.23s}
.card:nth-child(9){animation-delay:.26s}.card:nth-child(10){animation-delay:.29s}
.card:nth-child(11){animation-delay:.32s}.card:nth-child(12){animation-delay:.35s}
.card:nth-child(13){animation-delay:.38s}.card:nth-child(14){animation-delay:.41s}
.card:nth-child(15){animation-delay:.44s}.card:nth-child(16){animation-delay:.47s}
.card:nth-child(17){animation-delay:.50s}.card:nth-child(18){animation-delay:.53s}
.card:nth-child(19){animation-delay:.56s}.card:nth-child(20){animation-delay:.59s}
.card:nth-child(21){animation-delay:.62s}.card:nth-child(22){animation-delay:.65s}
.card:nth-child(23){animation-delay:.68s}.card:nth-child(24){animation-delay:.71s}

/* 尊重「減少動態」偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .card { transition-duration: 0.2s; }
}

/* ============================================================================
   App 結構骨架（畫面切換 / 版面 / 觸控）— 非設計交付物，由遊戲程式需要
   ============================================================================ */
* { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

html, body {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

#app { position: relative; height: 100%; height: 100dvh; }

/* 三個畫面疊在一起，靠 .active 切換 */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}
.screen.active { display: flex; }
/* 開始 / 結算畫面置中（卡片本身 margin:auto） */
#screen-start, #screen-end { overflow: auto; }

/* 牌陣容器：佔滿剩餘空間並置中，供 JS 量測尺寸 */
.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px clamp(8px, 2vw, 16px) 12px;
}
.board-wrap .board { margin: 0 auto; } /* JS 會設定寬度，這裡只負責置中 */

/* 真實撲克牌面圖（Vector-Playing-Cards，公眾領域） */
.face-front { padding: 0; }
.card-img {
  width: 100%;
  height: 100%;
  object-fit: fill;       /* 填滿牌面；SVG 比例與牌面差 <4%，視覺無感 */
  border-radius: inherit;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

/* 配對判定/翻牌動畫期間鎖定點擊（保險，邏輯層也會擋） */
.card.locked { pointer-events: none; }

/* 單人模式最佳紀錄提示 */
.best-note {
  margin: 2px 2px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
