/* =========================================================
   全站共用樣式
   ========================================================= */
:root {
  --felt: #0f4d32;        /* 麻將桌綠 */
  --felt-light: #1a6b47;
  --gold: #f4c95d;
  --text: #f5f1e6;
  --text-dim: #cfe3d6;
  --card: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 70%);
  background-attachment: fixed;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--gold); }

/* 按鈕 */
.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #1d3b2c;
  background: #f5f1e6;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.btn-primary { background: var(--gold); color: #3a2a00; }

/* 一般頁面容器 */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(100px + env(safe-area-inset-bottom));
}
.container h1 { margin: 0 0 6px; font-size: 28px; }
.container .lead { margin: 0 0 24px; color: var(--text-dim); }

/* 上方列（遊戲頁用） */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(0, 0, 0, 0.25);
}
.back-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

/* 選單卡片 */
.card-list {
  display: grid;
  gap: 14px;
}
.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
}
.card:hover { background: rgba(255, 255, 255, 0.14); }
.card-icon {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: rgba(0, 0, 0, 0.25);
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card p { margin: 0; font-size: 14px; color: var(--text-dim); }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  vertical-align: middle;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
}
.badge-new { background: var(--gold); color: #3a2a00; }
.card p.best-score { margin-top: 6px; color: var(--gold); font-weight: 600; }

/* =========================================================
   PWA「安裝到主畫面」提示列（由 js/pwa.js 產生）
   ========================================================= */
.pwa-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 200000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fffaf0;
  color: #2b2b2b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  animation: pwa-up 0.3s ease-out;
}
.pwa-banner-text { flex: 1; line-height: 1.4; }
.pwa-banner .btn { padding: 8px 12px; font-size: 14px; }
.pwa-banner .pwa-close {
  background: transparent;
  box-shadow: none;
  color: #777;
}
@keyframes pwa-up {
  from { transform: translateY(30px); opacity: 0; }
}

/* =========================================================
   提示訊息、對話框、彩帶（翻牌與對電腦共用）
   ========================================================= */
/* ---------- 提示訊息 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 150000;
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 對話框 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fffaf0;
  color: #333;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: modal-in 0.25s ease-out;
}
@keyframes modal-in {
  from { transform: scale(0.85); opacity: 0; }
}
.modal-box h2 { margin: 0 0 10px; font-size: 22px; }
.modal-box p { margin: 0 0 12px; color: #555; }
.modal-box .muted { color: #888; font-size: 14px; }
.modal-box .warn { color: #c0281c; font-weight: 600; }
.modal-box .new-record {
  color: #c27a0a;
  font-size: 20px;
  font-weight: 800;
  animation: modal-in 0.5s ease-out;
}
.modal-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
}
.score-table {
  width: 100%;
  margin: 0 0 12px;
  border-collapse: collapse;
  font-size: 15px;
}
.score-table td { padding: 4px 6px; border-bottom: 1px solid #eee2c6; }
.score-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.score-table .total td { font-size: 18px; font-weight: 800; color: #1b5e3a; border-bottom: 0; }

/* ---------- 過關彩帶 ---------- */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 200200; /* 飄在過關對話框上面 */
  pointer-events: none;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); }
}

