:root {
  --bg: #e7ebf1;
  --bg-2: #d6dde8;
  --panel: #fbfcfe;
  --panel-2: #eef1f6;
  --ink: #1b2440;
  --ink-soft: #5a6585;
  --line: #cdd5e2;
  --gold: #e0ac3c;
  --gold-ink: #2a1d00;
  --lantern: #c22f3a;
  --shadow: 0 4px 14px rgba(27, 36, 64, .14);
  --r: 12px;
  --font-display: "Lora", Georgia, serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  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: #18203d; --bg-2: #0e1328; --panel: #222c4e; --panel-2: #2a3458;
    --ink: #eef0f8; --ink-soft: #a6afcf; --line: #34406a; --shadow: 0 4px 14px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18203d; --bg-2: #0e1328; --panel: #222c4e; --panel-2: #2a3458;
  --ink: #eef0f8; --ink-soft: #a6afcf; --line: #34406a; --shadow: 0 4px 14px rgba(0, 0, 0, .4);
  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(90% 40% at 15% -5%, color-mix(in srgb, var(--lantern) 22%, transparent), transparent 70%),
    radial-gradient(70% 35% at 95% 0%, color-mix(in srgb, var(--gold) 16%, 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; }

/* ---------- 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; }
.lanterns { display: flex; gap: 14px; height: 92px; align-items: flex-start; }
.lanterns span { width: 34px; height: 46px; border-radius: 50% / 46%; position: relative; margin-top: var(--d); box-shadow: 0 0 22px var(--c); background: var(--c); }
.lanterns span::before { content: ""; position: absolute; left: 50%; top: calc(-1 * var(--d) - 2px); height: var(--d); border-left: 1.5px solid var(--ink-soft); }
.lanterns span::after { content: ""; position: absolute; left: 8px; right: 8px; top: -3px; bottom: -3px; border-top: 4px solid var(--gold); border-bottom: 4px solid var(--gold); border-radius: 3px; }
.logo { font: 700 50px/1 var(--font-display); margin: 0; letter-spacing: -.5px; }
.tagline { font-size: 18px; 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(--gold); color: var(--gold-ink); border-color: transparent; font-weight: 700; }
.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: 700 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: 10px 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); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Hàng hoá ---------- */
.gem { --gc: #999; --gi: #fff; background: var(--gc); color: var(--gi); }
.g-gom { --gc: #f1ede3; --gi: #3a3326; }
.g-cham { --gc: #2c4f9e; --gi: #fff; }
.g-tra { --gc: #2f8a4e; --gi: #fff; }
.g-lua { --gc: #c22f3a; --gi: #fff; }
.g-tram { --gc: #3b2a22; --gi: #fff; }
.g-gold { --gc: #e0ac3c; --gi: #2a1d00; }

/* ---------- Trong ván ---------- */
.game { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 8px 10px 0; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.pl { background: var(--panel); border-radius: 14px; padding: 7px 8px 6px; border: 2px solid transparent; text-align: left; min-width: 0; position: relative; }
.pl.active { border-color: var(--pc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 22%, transparent); }
.pl .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 5px; align-items: center; padding-right: 28px; }
.pl .pts { position: absolute; right: 9px; top: 5px; font: 700 20px/1 var(--font-display); }
.pl .mini { display: flex; gap: 3px; margin-top: 6px; }
.pl .mini i { flex: 1; height: 15px; border-radius: 4px; font: 700 10px/15px var(--font-body); font-style: normal; text-align: center; }
.pl .mini i.z { opacity: .28; }
.pl .meta { font-size: 11px; color: var(--ink-soft); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 2px; min-height: 30px; }
.status .msg { font-weight: 600; font-size: 14px; }
.status .timer { font-weight: 700; color: var(--ink-soft); font-size: 14px; }

/* Quý nhân: thẻ lụa vàng */
.nobles { display: flex; gap: 6px; }
.noble { flex: 1; max-width: 116px; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 5px 7px 5px 5px; border-radius: 10px; color: #3a2606;
  background: linear-gradient(135deg, #f8e7b8 0%, #e9c46a 55%, #d9a843 100%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.55), 0 3px 10px rgba(0,0,0,.25); }
.noble .seal { width: 26px; height: 26px; flex: none; border-radius: 7px; background: #b8322d; color: #fff3d6; display: grid; place-items: center; font: 700 16px/1 var(--font-display); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.noble .req { display: flex; flex-wrap: wrap; gap: 2px; }
.noble .req i { width: 17px; height: 19px; border-radius: 4px; font: 700 10px/19px var(--font-body); font-style: normal; text-align: center; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }

/* Chợ thẻ: thẻ giấy dó, dải màu hàng ở trên */
.market { display: flex; flex-direction: column; gap: 7px; }
.tier { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 6px; }
.card { aspect-ratio: 5 / 7; border-radius: 10px; padding: 3px; position: relative; text-align: left; min-width: 0; overflow: hidden;
  background: linear-gradient(170deg, #fffaf0 0%, #f2e6cc 100%); color: #2b2418;
  border: 0; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 12px rgba(0,0,0,.22); display: flex; flex-direction: column; }
.card .top { background: linear-gradient(160deg, color-mix(in srgb, var(--gc) 82%, #fff) 0%, var(--gc) 70%); color: var(--gi);
  border-radius: 7px; display: flex; justify-content: space-between; align-items: flex-start; padding: 4px 5px; height: 36%; position: relative; z-index: 1; }
.card .top b { font: 700 24px/1 var(--font-display); text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.card.g-gom .top b { text-shadow: none; }
.card .top span { font-size: 15px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.card .wm { position: absolute; right: -6px; bottom: -4px; font-size: 46px; opacity: .14; filter: grayscale(1); pointer-events: none; }
.card .cost { margin-top: auto; padding: 2px; display: grid; grid-template-columns: repeat(2, max-content); gap: 3px; align-content: end; position: relative; z-index: 1; }
.card .cost i { width: 20px; height: 20px; border-radius: 50%; font: 700 11px/20px var(--font-body); font-style: normal; text-align: center;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--gc) 55%, #fff) 0%, var(--gc) 62%); box-shadow: 0 0 0 1.5px #fffaf0, 0 1px 2px rgba(0,0,0,.35); }
.card.can { box-shadow: 0 0 0 2.5px var(--gold), 0 0 16px color-mix(in srgb, var(--gold) 55%, transparent); }
.card.can::after { content: "Mua được"; position: absolute; right: 4px; bottom: 4px; z-index: 2; font-size: 9px; font-weight: 700; background: var(--gold); color: var(--gold-ink); border-radius: 5px; padding: 1px 4px; }
.card.empty { background: transparent; box-shadow: none; border: 2px dashed var(--line); }
.deck { aspect-ratio: 5 / 7; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #fff;
  font-weight: 600; font-size: 11px; border: 0; position: relative; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.deck::before { content: ""; position: absolute; inset: 4px; border-radius: 7px; border: 1.5px solid rgba(255,255,255,.45); }
.deck.t1 { background: radial-gradient(circle at 50% 40%, #3a9c5c, #23683c); }
.deck.t2 { background: radial-gradient(circle at 50% 40%, #d89a2c, #9a6410); }
.deck.t3 { background: radial-gradient(circle at 50% 40%, #3b62b8, #1f3a7a); }
.deck .lv { font: 700 22px/1 var(--font-display); }
.deck .cnt { background: rgba(0,0,0,.28); border-radius: 999px; padding: 1px 8px; }
.deck:disabled { opacity: .35; }

/* Kho hàng: thẻ bài tròn kiểu poker */
.bank { display: flex; justify-content: space-between; gap: 4px; padding: 2px 2px 0; }
.tok { width: min(15vw, 58px); aspect-ratio: 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; border: 0;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--gc) 70%, #fff) 0%, var(--gc) 58%, color-mix(in srgb, var(--gc) 80%, #000) 100%);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--gc) 60%, #000), 0 6px 12px rgba(0,0,0,.3); transition: transform .12s ease; }
.tok::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--gi) 45%, transparent); }
.tok .ic { font-size: 17px; line-height: 1; position: relative; }
.tok .n { position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); background: var(--panel); color: var(--ink); font-weight: 700; font-size: 12px; line-height: 18px; min-width: 22px; border-radius: 999px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.tok.sel { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--gold), 0 9px 16px rgba(0,0,0,.35); }
.tok .sel-n { position: absolute; top: -6px; right: -6px; background: var(--gold); color: var(--gold-ink); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; }
.tok:disabled { opacity: .35; }
.tok.g-gold:disabled { opacity: 1; cursor: default; }
@media (prefers-reduced-motion: reduce) { .tok { transition: none; } }

.tray { margin-top: auto; background: var(--panel); border-radius: 20px 20px 0 0; margin-left: -10px; margin-right: -10px; padding: 12px 12px 12px; box-shadow: 0 -6px 20px rgba(0, 0, 0, .18); display: flex; flex-direction: column; gap: 10px; }
.mine { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.mine .col { border-radius: 10px; padding: 5px 0 4px; text-align: center; position: relative;
  background: linear-gradient(160deg, color-mix(in srgb, var(--gc) 80%, #fff) 0%, var(--gc) 75%); color: var(--gi); }
.mine .col .ic { font-size: 13px; }
.mine .col .v { font: 700 18px/1.1 var(--font-display); }
.mine .col small { display: block; font-size: 10px; opacity: .9; font-family: var(--font-body); font-weight: 600; }
.bar { display: flex; gap: 8px; align-items: center; }
.bar .btn { flex: 1; min-height: 44px; padding: 8px; font-size: 14px; }
.pickline { display: flex; align-items: center; gap: 8px; }
.pickline .chips { display: flex; gap: 4px; flex: 1; }
.pickline .chips i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 14px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }

/* ---------- Bảng trượt ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 30, .5); 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: 85vh; 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; } }
.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; }
.big-card { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.big-card .card { width: 110px; flex: none; }
.big-card .card .top b { font-size: 30px; }
.big-card .card .top span { font-size: 22px; }
.big-card .card .cost i { width: 26px; height: 26px; line-height: 26px; font-size: 13px; }
.big-card .card .wm { font-size: 70px; }
.paylist { font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.paylist .r { display: flex; align-items: center; gap: 6px; }
.paylist i { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-style: normal; font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stepper { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 12px; }
.stepper .col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stepper .chip { width: 100%; border-radius: 9px; text-align: center; padding: 6px 0; }
.stepper .chip b { display: block; font-size: 15px; }
.stepper .pm { display: flex; gap: 3px; }
.stepper .pm button { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); font-weight: 700; }
.rlist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.rlist .hidden-card { aspect-ratio: 5/7; border-radius: 9px; }
.nob-opt { display: flex; gap: 8px; margin-bottom: 12px; }
.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 .trophy { font-size: 60px; }
.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; font: 700 20px var(--font-display); }

/* ---------- Mèo ---------- */
.cat { display: inline-block; line-height: 0; }
.cat svg { width: 100%; height: 100%; display: block; }
.tok .ic { position: relative; width: 74%; height: 74%; display: grid; place-items: center; }
.tok .ic .cat { width: 100%; height: 100%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.tok::before { inset: 3px; }
.card .top span .cat { width: 20px; height: 20px; }
.card .art { position: absolute; right: -2%; bottom: 1%; width: 78%; aspect-ratio: 1; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(60,40,10,.18)); }
.card .art svg { width: 100%; height: 100%; display: block; }
.card .cost { z-index: 2; }
.big-card .card .art { width: 80%; }
.mine .col .ic .cat { width: 22px; height: 22px; }
.mine .col .ic { height: 22px; display: flex; justify-content: center; }
.pickline .chips i .cat, .paylist i .cat { width: 80%; height: 80%; }
.stepper .chip .cat { width: 24px; height: 24px; }
.noble { max-width: none; padding: 4px 8px 4px 4px; gap: 4px; }
.noble .por { width: 40px; height: 50px; flex: none; background: radial-gradient(circle at 50% 40%, #fff6dc, #f0d388); border-radius: 8px; box-shadow: inset 0 0 0 1.5px rgba(150,100,20,.45); overflow: hidden; }
.noble .por svg { width: 100%; height: 100%; display: block; }
.noble .nb { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.noble .seal { width: 22px; height: 22px; font-size: 14px; }
.cat-row { display: flex; gap: 8px; margin-bottom: 4px; }
.cat-row .tok { width: 48px; }
.cat-row .tok .cat { width: 72%; height: 72%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.cat-row .tok:nth-child(odd) { transform: translateY(8px); }
.card .cost { grid-template-columns: max-content; gap: 2px; }
.card .cost.c4 { grid-template-columns: repeat(2, max-content); }
.card .cost i { width: 18px; height: 18px; line-height: 18px; font-size: 10.5px; }
.card .art { width: 70%; right: -4%; bottom: 0; }
.big-card .card .cost i { width: 24px; height: 24px; line-height: 24px; font-size: 12px; }

/* 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: var(--gold-ink); --danger: var(--lantern); --r-sm: 10px; --r-lg: 18px; }
.home .back { color: var(--ink-soft); font-size: 14px; text-decoration: none; align-self: flex-start; }
.status .row { gap: 4px; }
.status .row .btn.small { min-height: 34px; padding: 4px 9px; }
.status .timer.low { color: var(--lantern); }
.lobby { padding-bottom: 76px; }
.tray > .hint, .tray > .pickline { margin-right: 92px; min-height: 42px; }
.tray > .pickline { flex-wrap: wrap; row-gap: 6px; }

/* Bàn 5–6 người: hàng người chơi xếp 3 cột × 2 dòng, chợ 5 thẻ mỗi tầng nên thẻ gọn lại chút */
.players.many { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.players.many .pl { padding: 5px 6px 4px; }
.players.many .pl .mini i { height: 13px; line-height: 13px; }
.market[style*="--cols:6"] .tier { gap: 4px; }
/* 6–7 quý nhân (bàn 5–6 người): xếp dọc chân dung trên, điều kiện dưới cho vừa một hàng */
.nobles.many { gap: 4px; }
.nobles.many .noble { flex-direction: column; align-items: center; padding: 4px 3px; gap: 3px; }
.nobles.many .noble .por { width: 34px; height: 40px; }
.nobles.many .noble .nb { flex-direction: row; align-items: flex-start; gap: 2px; }
.nobles.many .noble .seal { display: none; }
.nobles.many .noble .req { justify-content: center; }
.nobles.many .noble .req i { width: 15px; height: 17px; line-height: 17px; }
