/* [claude code] 2026-07-19 建立 — brian_joy client 樣式（休閒益智風，紫藍漸層 + 卡片） */
:root {
  --brand: #6d5efc;
  --brand-2: #38bdf8;
  --ink: #29304a;
  --ink-soft: #6b7391;
  --bg-card: #ffffff;
  --line: #e6e8f2;
  --bad: #ef4444;
  --good: #16a34a;
  --sel: #dbe4ff;
  --peer: #eef2ff;
  --same: #c7d6ff;
  --shadow: 0 8px 24px rgba(80, 70, 160, .12);
}
* { box-sizing: border-box; }
/* hidden 屬性一律隱藏：.modal / .sd-win / #boot 都有 display:flex，會蓋掉瀏覽器內建的
   [hidden]{display:none}，導致 hidden=true 卻關不掉。用 !important 強制生效（modal 開關、
   載入層、完成慶祝層、view 切換都靠這個）。 [claude code] 2026-07-19 修 modal 關不掉 bug */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(160deg, #f3e7ff 0%, #e0f2fe 100%);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; border: none; }

/* ── topbar ─────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; max-width: 560px; margin: 0 auto;
}
.brand { font-size: 20px; font-weight: 800; color: var(--brand); display: flex; align-items: baseline; gap: 6px; }
.brand small { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.chip {
  background: #fff; color: var(--brand); font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow);
}
.chip:active { transform: scale(.96); }
.top-right { display: flex; align-items: center; gap: 8px; }
.coin-chip { background: linear-gradient(135deg, #fff7e0, #ffe6ad); color: #a86b00; font-weight: 800; font-size: 13px; padding: 8px 12px; border-radius: 999px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.coin-chip b { font-variant-numeric: tabular-nums; }

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 40px; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── 大廳 ───────────────────────────────── */
.lobby-hero { margin: 6px 2px 14px; }
.hero-title { font-size: 22px; font-weight: 900; color: var(--ink); }
.hero-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.lobby-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 14px; scrollbar-width: none; }
.lobby-tabs::-webkit-scrollbar { display: none; }
.lobby-tab { flex: 0 0 auto; background: #fff; color: var(--ink-soft); font-weight: 700; font-size: 13px; padding: 9px 14px; border-radius: 999px; box-shadow: 0 2px 8px rgba(80,70,160,.08); white-space: nowrap; display: flex; align-items: center; gap: 5px; transition: transform .12s; }
.lobby-tab:active { transform: scale(.95); }
.lobby-tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 12px rgba(109,94,252,.35); }
.tab-count { background: rgba(0,0,0,.12); border-radius: 999px; padding: 0 6px; font-size: 11px; line-height: 16px; min-width: 16px; text-align: center; }
.lobby-tab.active .tab-count { background: rgba(255,255,255,.3); }

.game-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.game-card {
  position: relative; background: var(--bg-card); border-radius: 20px; padding: 22px 14px 16px; text-align: center;
  box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .14s ease;
  display: flex; flex-direction: column; align-items: center; gap: 7px; overflow: hidden;
  border: 1px solid rgba(109,94,252,.06);
}
.game-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.game-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(80,70,160,.18); }
.game-card:active { transform: scale(.97); }
.gc-icon { width: 62px; height: 62px; border-radius: 18px; background: linear-gradient(135deg, #efeaff, #e0f2fe); display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(109,94,252,.1); }
.gc-icon span { font-size: 34px; }
.gc-title { font-size: 17px; font-weight: 800; }
.gc-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.5; min-height: 34px; }
.gc-play { font-size: 12px; font-weight: 800; color: var(--brand); }

.lobby-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); font-size: 14px; padding: 40px 20px; background: rgba(255,255,255,.5); border-radius: 18px; border: 1.5px dashed var(--line); }

/* ── 帳號 modal ─────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(30, 24, 60, .45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-card { background: #fff; border-radius: 20px; width: 100%; max-width: 340px; padding: 22px; position: relative; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; font-size: 18px; color: var(--ink-soft); }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; border-radius: 12px; background: #f1f3fb; color: var(--ink-soft); font-weight: 700; }
.tab.active { background: var(--brand); color: #fff; }
.field { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 15px; margin-bottom: 10px; outline: none; }
.field:focus { border-color: var(--brand); }
.ac-msg { color: var(--bad); font-size: 13px; min-height: 18px; margin: 2px 2px 8px; }
.btn-primary { width: 100%; padding: 13px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; font-size: 15px; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; }
.ac-note { font-size: 11px; color: var(--ink-soft); line-height: 1.6; margin: 12px 2px 0; }

/* ── 數獨 ───────────────────────────────── */
.sd-wrap { display: flex; flex-direction: column; gap: 12px; }
.sd-head { display: flex; align-items: center; gap: 10px; }
.sd-back { background: #fff; color: var(--ink); font-weight: 700; padding: 8px 12px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }
.sd-diffs { display: flex; gap: 6px; flex: 1; justify-content: center; }
.sd-diff { padding: 7px 10px; border-radius: 10px; background: #fff; color: var(--ink-soft); font-weight: 700; font-size: 12px; box-shadow: 0 2px 8px rgba(80,70,160,.08); }
.sd-diff.active { background: var(--brand); color: #fff; }
.sd-timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--brand); min-width: 52px; text-align: right; }

.sd-board {
  display: grid; grid-template-columns: repeat(9, 1fr); aspect-ratio: 1;
  background: #fff; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); user-select: none;
}
.sd-cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 6vw, 30px); font-weight: 700; color: var(--brand);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  aspect-ratio: 1;
}
.sd-cell.br { border-right: 2.5px solid var(--ink); }
.sd-cell.bb { border-bottom: 2.5px solid var(--ink); }
.sd-cell.given { color: var(--ink); font-weight: 800; }
.sd-cell.hint { color: var(--good); }
.sd-cell.peer { background: var(--peer); }
.sd-cell.same { background: var(--same); }
.sd-cell.sel { background: var(--sel); box-shadow: inset 0 0 0 2px var(--brand); }
.sd-cell.bad { color: var(--bad) !important; background: #fee2e2; }
.sd-cell.notes { color: var(--ink-soft); }
.sd-cell.notes { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); font-size: 0; }
.sd-cell.notes i { font-style: normal; font-size: clamp(7px, 2vw, 10px); display: flex; align-items: center; justify-content: center; color: var(--ink-soft); }

.sd-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.sd-key {
  background: #fff; border-radius: 12px; padding: 14px 0; font-size: 22px; font-weight: 800;
  color: var(--brand); box-shadow: var(--shadow);
}
.sd-key:active { transform: scale(.95); background: var(--sel); }
.sd-erase { color: var(--ink-soft); }

.sd-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sd-act { background: #fff; border-radius: 12px; padding: 11px 4px; font-size: 13px; font-weight: 700; color: var(--ink); box-shadow: var(--shadow); }
.sd-act:active { transform: scale(.96); }
.sd-act.on { background: var(--brand); color: #fff; }
.sd-new { color: var(--brand); }

/* ── 完成慶祝 ───────────────────────────── */
.sd-win { position: fixed; inset: 0; background: rgba(30, 24, 60, .5); display: flex; align-items: center; justify-content: center; z-index: 60; animation: fade .2s ease; }
.sd-win-card { background: #fff; border-radius: 22px; padding: 30px 26px; text-align: center; box-shadow: var(--shadow); }
.sd-win-emoji { font-size: 56px; animation: pop .5s cubic-bezier(.2,1.4,.5,1); }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.sd-win-title { font-size: 24px; font-weight: 900; margin: 6px 0; color: var(--brand); }
.sd-win-sub { font-size: 14px; color: var(--ink-soft); margin-bottom: 18px; }
.sd-win-btns { display: flex; flex-direction: column; gap: 10px; }

/* ── toast ──────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(12px);
  background: rgba(41, 48, 74, .94); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .25s ease, transform .25s ease; z-index: 70;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  .sd-act { font-size: 12px; }
  .sd-diff { padding: 6px 8px; }
}

/* ── 共用 UI（給移植自 game_town 的遊戲用；別名 + 基礎元件）───────── */
:root {
  --border: var(--line);
  --card: var(--bg-card);
  --accent: var(--brand);
  --soft: var(--ink-soft);
  --mute: #9aa1bd;
}
.btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn.wide { width: 100%; }
.panel { background: var(--bg-card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: bjspin .8s linear infinite; }
@keyframes bjspin { to { transform: rotate(360deg); } }

/* 通用 confirm 對話框（ctx.confirm）*/
.bj-confirm-ov { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; background: rgba(30,24,60,.5); padding: 20px; }
.bj-confirm { background: #fff; border-radius: 20px; padding: 22px; max-width: 320px; width: 100%; box-shadow: var(--shadow); animation: pop .3s cubic-bezier(.2,1.3,.4,1) both; }
.bj-confirm .cf-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.bj-confirm .cf-msg { font-size: 14px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 16px; }
.bj-confirm .cf-btns { display: flex; gap: 10px; }
.bj-confirm .cf-btns .btn { flex: 1; text-align: center; }
.bj-confirm .cf-danger { background: linear-gradient(135deg, #ef4444, #f87171); }
