:root {
  --bg: #f1e9ec;
  --bg-2: #e4d6db;
  --panel: #fffafb;
  --panel-2: #f5ecef;
  --ink: #2a1418;
  --ink-soft: #78585f;
  --line: #e1cfd5;
  --lacquer: #a3232f;
  --gold: #c8962e;
  --gold-soft: #f2d48a;
  --shadow: 0 4px 14px rgba(60, 15, 25, .14);
  --r: 14px;
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --c-thaisu: #6d3a8f; --c-thichkhach: #2b2a33; --c-tuongquan: #2c4f9e; --c-suthan: #2f8a4e; --c-hoanghau: #c22f3a;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1116; --bg-2: #12090c; --panel: #2c1a20; --panel-2: #3a242b;
    --ink: #f7ebee; --ink-soft: #c2a2aa; --line: #4b2f37; --shadow: 0 4px 14px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1116; --bg-2: #12090c; --panel: #2c1a20; --panel-2: #3a242b;
  --ink: #f7ebee; --ink-soft: #c2a2aa; --line: #4b2f37; --shadow: 0 4px 14px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  background:
    radial-gradient(80% 35% at 50% -6%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
  background-color: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#app { min-height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; }
.cat svg, .por svg { width: 100%; height: 100%; display: block; }
.por { display: block; }

/* ---------- Trang chủ, sảnh ---------- */
.home, .lobby { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 22px; gap: 16px; }
.lobby { justify-content: flex-start; }
.court { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-bottom: 4px; }
.court .por { width: 64px; height: 84px; }
.court .por:nth-child(3) { width: 82px; height: 108px; }
.court .por:nth-child(2), .court .por:nth-child(4) { height: 94px; width: 72px; }
.logo { font: 800 54px/1 var(--font-display); margin: 0; letter-spacing: -.5px; }
.tagline { font-size: 17px; color: var(--ink-soft); margin: -4px 0 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.input { background: var(--panel); border: 2px solid var(--line); border-radius: var(--r); padding: 12px 14px; width: 100%; min-width: 0; }
.input:focus { border-color: var(--gold); outline: none; }
.row { display: flex; gap: 8px; align-items: center; }
.btn { padding: 12px 18px; border-radius: var(--r); font-weight: 600; background: var(--panel); border: 2px solid var(--line); white-space: nowrap; min-height: 46px; }
.btn.primary { background: var(--lacquer); color: #fff6e6; border-color: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--gold) 70%, transparent); }
.btn.gold { background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #2a1a00; border-color: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.code { font: 800 46px/1 var(--font-display); letter-spacing: 6px; }
.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seat { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--r); padding: 8px 12px; }
.seat .name { flex: 1; font-weight: 600; }
.seat .tag { font-size: 12px; color: var(--ink-soft); }
.seat.empty { background: transparent; border: 2px dashed var(--line); color: var(--ink-soft); padding: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }
.ava { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--panel-2); box-shadow: 0 0 0 2.5px var(--pc, var(--line)); display: grid; place-items: center; overflow: hidden; }
.ava .cat { width: 82%; height: 82%; margin-top: 4px; }

/* ---------- Trong ván ---------- */
.game { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 10px 10px 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font: 800 24px/1 var(--font-display); margin: 0; }
.topbar .row { gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); font-size: 17px; font-weight: 700; }
.opps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.opps.n1 { grid-template-columns: 1fr; }
.opps.n2, .opps.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opp { background: var(--panel); border-radius: var(--r); padding: 8px; display: flex; flex-direction: column; gap: 6px; border: 2px solid transparent; position: relative; min-width: 0; text-align: left; }
.opp.turn { border-color: var(--pc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 22%, transparent); }
.opp.out { opacity: .55; }
.opp.pick { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 35%, transparent); cursor: pointer; }
.opp .hd { display: flex; align-items: center; gap: 7px; min-width: 0; }
.opp .nm { font-weight: 600; font-size: 12.5px; line-height: 1.2; overflow-wrap: anywhere; }
.opp .ava { width: 30px; height: 30px; }
.opp .coins { font: 700 13px var(--font-body); color: var(--ink-soft); }
.opp .slots { display: flex; gap: 4px; }
.mini { width: 30px; height: 42px; border-radius: 6px; flex: none; overflow: hidden; position: relative; }
.mini.back, .bigcard.back { background: repeating-linear-gradient(45deg, #7d1a24 0 5px, #6a1520 5px 10px); box-shadow: inset 0 0 0 2px var(--gold); }
.mini.back::after { content: "❖"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--gold-soft); font-size: 13px; }
.mini.dead { background: var(--panel-2); filter: grayscale(1); opacity: .7; }
.mini.dead::after { content: ""; position: absolute; left: -4px; right: -4px; top: 50%; border-top: 2px solid var(--lacquer); transform: rotate(-35deg); }
.badge-act { position: absolute; top: -7px; right: 6px; background: var(--gold); color: #2a1a00; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }

.event { background: var(--panel); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; border: 1.5px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.event .line { display: flex; align-items: center; gap: 10px; }
.event .claim { width: 44px; height: 58px; flex: none; border-radius: 8px; overflow: hidden; background: var(--rc); }
.event .txt b { font-size: 15px; display: block; }
.event .txt span { font-size: 13px; color: var(--ink-soft); }
.event .btns { display: flex; gap: 6px; flex-wrap: wrap; }
.event .btns .btn { flex: 1; min-width: 30%; min-height: 44px; padding: 8px 10px; font-size: 14px; }
.event .timer { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--gold); transition: width 1s linear; }
.event .recent { font-size: 12px; color: var(--ink-soft); border-top: 1px dashed var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 2px; }

.me { display: flex; gap: 8px; align-items: stretch; }
.me .hand { display: flex; gap: 8px; flex: 1; }
.bigcard { flex: 1; border-radius: 14px; padding: 6px 6px 8px; background: linear-gradient(170deg, color-mix(in srgb, var(--rc) 75%, #fff) 0%, var(--rc) 60%); color: #fff; position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--gold) 80%, transparent), var(--shadow); min-width: 0; }
.bigcard .por { width: 76%; aspect-ratio: 92 / 120; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.35), transparent 70%); }
.bigcard b { font: 700 16px/1.1 var(--font-display); margin-top: 2px; }
.bigcard small { font-size: 11px; opacity: .92; line-height: 1.3; }
.bigcard.dead { filter: grayscale(1); opacity: .55; }
.bigcard.dead::after { content: "Đã lộ"; position: absolute; top: 42%; left: -6px; right: -6px; background: var(--lacquer); color: #fff; font-weight: 700; font-size: 13px; transform: rotate(-12deg); padding: 2px 0; }
.purse { width: 74px; flex: none; border-radius: 14px; background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #2a1a00; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.purse .n { font: 800 34px/1 var(--font-display); }
.purse small { font-size: 12px; font-weight: 600; }

.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.act { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); text-align: left; min-height: 54px; border-left: 4px solid var(--rc, var(--line)); position: relative; }
.act .th { width: 30px; height: 38px; flex: none; border-radius: 6px; overflow: hidden; background: var(--rc); }
.act .ic { width: 30px; height: 30px; flex: none; display: grid; place-items: center; font-size: 20px; }
.act b { display: block; font-size: 14px; }
.act small { display: block; font-size: 11px; color: var(--ink-soft); line-height: 1.25; }
.act .tag { position: absolute; top: 5px; right: 6px; font-size: 9.5px; font-weight: 700; padding: 0 6px; border-radius: 999px; }
.act .tag.true { background: #d6f0dc; color: #1c6b34; }
.act .tag.lie { background: #fbdada; color: #9c1f2b; }
.act:disabled { opacity: .4; cursor: not-allowed; }
.act.must { box-shadow: 0 0 0 3px var(--gold); }

/* ---------- Bảng trượt ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 5, 10, .55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); max-height: 86vh; overflow: auto; }
.sheet.anim { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet.anim { animation: none; } .event .timer { transition: none; } }
.sheet h2 { font: 700 22px/1.2 var(--font-display); margin: 0 0 4px; }
.sheet .sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 14px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); margin-bottom: 8px; text-align: left; }
.opt .t { flex: 1; }
.opt .t b { display: block; }
.opt .t small { color: var(--ink-soft); font-size: 12px; }
.pickcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pickcards .bigcard { cursor: pointer; padding-bottom: 10px; }
.pickcards .bigcard.on { box-shadow: 0 0 0 4px var(--gold), var(--shadow); transform: translateY(-3px); }
.pickcards .bigcard.on::before { content: "✓"; position: absolute; top: 6px; right: 8px; background: var(--gold); color: #2a1a00; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; display: grid; place-items: center; }
.rules { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rule { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 12px; padding: 8px; }
.rule .th { width: 44px; height: 58px; flex: none; border-radius: 8px; overflow: hidden; background: var(--rc); }
.rule b { display: block; font-family: var(--font-display); font-size: 16px; }
.rule small { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; display: block; }
.log { list-style: none; padding: 0; margin: 0 0 12px; font-size: 13px; }
.log li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 40; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
.win { text-align: center; }
.win .por { width: 110px; height: 143px; margin: 0 auto; }
.rank { list-style: none; padding: 0; margin: 12px 0; text-align: left; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank li b { margin-left: auto; }

/* Gắn vào boardgame.oneclickaz.com: tên biến màu mà chat/mic/âm thanh dùng chung (social.css) cần */
:root { --sun: var(--gold); --sun-ink: #2a1d00; --danger: var(--lacquer); --r-sm: 10px; --r-lg: 18px; }
.home .back { color: var(--ink-soft); font-size: 14px; text-decoration: none; align-self: flex-start; }
.lobby { padding-bottom: 76px; }
.topbar .row { gap: 6px; }
