/* =========================================================================
 * Cờ Tướng — giao diện sơn mài.
 * Nền then xanh sẫm, thếp vàng, son đỏ, quân cờ trên giấy ngà.
 * Chữ: Be Vietnam Pro (giao diện) · Noto Serif SC (quân cờ) · JetBrains Mono (giờ)
 * Mobile-first. Từ 1040px chuyển sang bố cục hai cột.
 * ========================================================================= */
:root {
  /* Bốn tầng nền, sẫm dần xuống dưới */
  --ink-900: #0B1310;
  --ink-800: #101A16;
  --ink-700: #16231E;
  --ink-600: #1D2E27;
  --ink-500: #26392F;

  --gold: #C9A75C;
  --gold-bright: #E5C883;
  --gold-line: rgba(201, 167, 92, .16);
  --gold-line-2: rgba(201, 167, 92, .32);

  --cinnabar: #C1352A;
  --cinnabar-soft: #E2705F;
  --jade: #4E9B78;

  --text: #EAE5D9;
  --dim: #96A49B;
  --faint: #67766D;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 20px 44px -26px rgba(0, 0, 0, .95);
  --ring: 0 0 0 2px var(--gold-bright);
}

* { box-sizing: border-box; }

/* Các luật display bên dưới có ưu tiên cao hơn [hidden] của trình duyệt,
   nên phải ép lại. Thiếu dòng này là hộp thoại hiện ngay khi tải trang. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 640px at 50% -12%, #17281F 0%, transparent 62%),
    var(--ink-900);
  color: var(--text);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

.screen { display: none; min-height: 100dvh; }
.screen.show { display: block; }

/* ------------------------------- Nguyên tố ------------------------------ */
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.label {
  display: block; font-size: 11.5px; font-weight: 600;
  letter-spacing: .11em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 7px;
}
.label b { color: var(--gold); font-weight: 600; text-transform: none; letter-spacing: 0; }
.label-note { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--faint); }
.help { color: var(--dim); font-size: 13px; margin: 7px 0 0; }
.minor { font-size: 11.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; color: var(--dim); margin: 0 0 8px; }
.footnote { color: var(--faint); font-size: 12.5px; margin-top: 22px; }
.footnote code { color: var(--gold); font-family: "JetBrains Mono", monospace; font-size: 11.5px; }
.form-error { min-height: 18px; margin: 2px 0 10px; font-size: 13px; color: var(--cinnabar-soft); }

.panel {
  background: linear-gradient(178deg, var(--ink-700), var(--ink-800));
  border: 1px solid var(--gold-line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }
.panel-narrow { max-width: 640px; margin: 0 auto; }
.panel-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 16px;
}
.panel-title .i { width: 15px; height: 15px; }
.panel-title .btn { margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 15px; min-height: 44px;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #14100A; border-color: var(--gold-bright); }
.btn-primary:hover:not(:disabled) { background: var(--gold-bright); }
.btn-quiet { background: transparent; color: var(--text); border-color: var(--gold-line-2); }
.btn-quiet:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); background: rgba(201, 167, 92, .07); }
.btn-danger { background: transparent; color: var(--cinnabar-soft); border-color: rgba(193, 53, 42, .45); }
.btn-danger:hover:not(:disabled) { background: rgba(193, 53, 42, .12); border-color: var(--cinnabar); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: 13px; border-radius: var(--r-sm); }
.btn-sm .i { width: 15px; height: 15px; }
.btn-icon { padding: 9px; min-width: 44px; }
.btn-icon .i { width: 20px; height: 20px; }

:where(.btn, .seg, .chip, .navtab, .railtab, input, select):focus-visible {
  outline: none; box-shadow: var(--ring);
}

.field { display: block; margin-bottom: 16px; }
input[type=text], input[type=password], select {
  width: 100%; font: inherit; font-size: 15px; color: var(--text);
  background: var(--ink-900);
  border: 1px solid var(--gold-line-2);
  border-radius: 10px; padding: 11px 13px; min-height: 46px;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: rgba(201, 167, 92, .48); }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
input[type=range] { width: 100%; accent-color: var(--gold); min-height: 30px; }

.segmented {
  display: flex; gap: 3px; padding: 3px;
  background: var(--ink-800); border: 1px solid var(--gold-line);
  border-radius: 11px; margin-bottom: 18px;
}
.seg {
  flex: 1; font: inherit; font-size: 13.5px; font-weight: 500;
  background: transparent; color: var(--dim); border: 0;
  border-radius: var(--r-sm); padding: 9px 6px; min-height: 40px; cursor: pointer;
}
.seg.is-on { background: var(--ink-600); color: var(--gold); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13.5px; font-weight: 500;
  background: var(--ink-900); color: var(--dim);
  border: 1px solid var(--gold-line-2); border-radius: 999px;
  padding: 8px 15px; min-height: 40px; cursor: pointer;
}
.chip:hover { border-color: rgba(201, 167, 92, .5); }
.chip.is-on { background: rgba(201, 167, 92, .13); border-color: var(--gold); color: var(--gold-bright); }

.pane { display: none; }
.pane.show { display: block; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  border: 1px solid var(--gold-line-2); color: var(--gold);
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.tag .i { width: 12px; height: 12px; stroke-width: 2; }
.tag-dark { border-color: rgba(78, 155, 120, .5); color: var(--jade); }
.tag-live { border-color: rgba(193, 53, 42, .5); color: var(--cinnabar-soft); }
.tag-done { border-color: rgba(150, 164, 155, .3); color: var(--faint); }
.taglist { display: flex; gap: 5px; flex-wrap: wrap; }

.notice {
  background: rgba(201, 167, 92, .1); border: 1px solid var(--gold-line-2);
  border-radius: var(--r); padding: 11px 13px; font-size: 13.5px;
  color: var(--gold-bright); margin-bottom: 16px;
}

.avatar {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--ink-600); border: 1px solid var(--gold-line-2);
  color: var(--gold); font-family: "Noto Serif SC", serif; font-size: 17px; line-height: 1;
}
.avatar-lg { width: 68px; height: 68px; font-size: 34px; border-width: 2px; }
.av-gold { color: #E5C883; border-color: rgba(229, 200, 131, .55); background: rgba(201, 167, 92, .14); }
.av-cinnabar { color: #E2705F; border-color: rgba(226, 112, 95, .5); background: rgba(193, 53, 42, .16); }
.av-jade { color: #6FC49C; border-color: rgba(111, 196, 156, .5); background: rgba(78, 155, 120, .16); }
.av-azure { color: #79AEDC; border-color: rgba(121, 174, 220, .5); background: rgba(60, 120, 175, .16); }
.av-plum { color: #C08CD0; border-color: rgba(192, 140, 208, .5); background: rgba(140, 90, 160, .16); }
.av-slate { color: #A6B5AC; border-color: rgba(166, 181, 172, .45); background: rgba(120, 138, 128, .16); }

.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 16px; }
.boot p { color: var(--faint); font-size: 14px; margin: 0; }
.boot-seal {
  width: 56px; height: 56px; display: grid; place-items: center;
  font-family: "Noto Serif SC", serif; font-size: 30px; color: #FFF1DA;
  background: var(--cinnabar); border: 2px solid var(--gold); border-radius: 13px;
}

/* ------------------------------ Đăng nhập ------------------------------- */
.auth { max-width: 440px; margin: 0 auto; padding: 46px 20px 64px; }
.auth-mark {
  width: 64px; height: 64px; display: grid; place-items: center;
  border: 2px solid var(--gold); border-radius: 14px;
  background: var(--cinnabar); box-shadow: 0 0 0 6px rgba(193, 53, 42, .13);
}
.auth-mark span { font-family: "Noto Serif SC", serif; font-size: 35px; color: #FFF1DA; line-height: 1; }
.auth-title { font-size: clamp(34px, 9vw, 48px); font-weight: 700; letter-spacing: -.025em; margin: 18px 0 8px; }
.auth-lede { color: var(--dim); margin: 0 0 26px; max-width: 33ch; }

/* --------------------------------- Sảnh -------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; padding-top: max(11px, env(safe-area-inset-top));
  background: rgba(11, 19, 16, .93); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gold-line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; }
.brand-name { font-size: 15px; }
.brand-seal {
  font-family: "Noto Serif SC", serif; background: var(--cinnabar); color: #FFF1DA;
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; font-size: 18px;
}
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.userchip {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 3px 10px 3px 3px; min-height: 44px;
}
.userchip:hover { border-color: var(--gold-line-2); background: rgba(201, 167, 92, .06); }
.userchip-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.userchip-text b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
.userchip-text small { font-size: 11.5px; color: var(--faint); font-family: "JetBrains Mono", monospace; }

.navtabs {
  display: flex; gap: 2px; padding: 0 14px;
  border-bottom: 1px solid var(--gold-line);
  background: rgba(11, 19, 16, .6);
  position: sticky; top: 61px; z-index: 19;
  overflow-x: auto; scrollbar-width: none;
}
.navtabs::-webkit-scrollbar { display: none; }
.navtab {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 500;
  background: transparent; color: var(--dim);
  border: 0; border-bottom: 2px solid transparent;
  padding: 12px 12px; min-height: 46px; cursor: pointer; white-space: nowrap;
}
.navtab .i { width: 16px; height: 16px; }
.navtab.is-on { color: var(--gold); border-bottom-color: var(--gold); }
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }

.lobby { padding: 18px 14px 70px; max-width: 1180px; margin: 0 auto; }
.lobby-grid { display: grid; gap: 16px; }

.roomlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.roomcard {
  display: flex; align-items: center; gap: 13px;
  background: var(--ink-800); border: 1px solid var(--gold-line);
  border-radius: var(--r); padding: 13px 14px;
}
.roomcard:hover { border-color: var(--gold-line-2); }
.roomcard-body { min-width: 0; flex: 1; }
.roomcard-title { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.roomcard-title .i { width: 14px; height: 14px; color: var(--gold); }
.roomcard-vs { font-size: 13px; color: var(--dim); margin: 3px 0 7px; }
.roomcard-vs .vs { color: var(--faint); margin: 0 6px; }
.roomcard .btn { flex: none; }
.empty { color: var(--faint); text-align: center; padding: 26px 0; font-size: 14px; }

/* Huy hiệu bậc, dùng chung bảng màu với avatar */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border: 1px solid currentColor; border-radius: 999px;
  padding: 2px 9px; white-space: nowrap;
}
.badge.av-gold, .badge.av-cinnabar, .badge.av-jade,
.badge.av-azure, .badge.av-plum, .badge.av-slate { background: transparent; }
.badge b { font-weight: 700; font-family: "JetBrains Mono", monospace; font-size: 10.5px; opacity: .8; }

.myrank {
  background: var(--ink-900); border: 1px solid var(--gold-line);
  border-radius: var(--r); padding: 14px; margin-bottom: 16px;
}
.myrank-top { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.myrank-top .who { flex: 1; min-width: 0; }
.myrank-top .who b { display: block; font-weight: 600; }
.myrank-top .who small { color: var(--faint); font-size: 12px; }
.bar { height: 6px; border-radius: 3px; background: var(--ink-600); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.myrank-note { color: var(--dim); font-size: 12.5px; margin: 8px 0 0; }

.ladder { list-style: none; margin: 0; padding: 0; counter-reset: ld; }
.ladder li {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 0; border-bottom: 1px solid var(--gold-line);
}
.ladder li:last-child { border-bottom: 0; }
.ladder li.is-me { background: rgba(201, 167, 92, .07); border-radius: var(--r-sm); padding-left: 8px; padding-right: 8px; }
.ladder .step { counter-increment: ld; width: 22px; flex: none; text-align: right;
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--faint); }
.ladder .lname { flex: 1; font-weight: 500; }
.ladder .lmin { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--dim); }

.delta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: "JetBrains Mono", monospace; font-size: 15px;
  background: var(--ink-900); border: 1px solid var(--gold-line);
  border-radius: var(--r); padding: 10px; margin: -6px 0 18px;
}
.delta .up { color: var(--jade); }
.delta .down { color: var(--cinnabar-soft); }
.delta small { font-family: "Be Vietnam Pro", sans-serif; color: var(--faint); font-size: 12px; }

.ranklist { list-style: none; counter-reset: rk; margin: 0; padding: 0; }
.ranklist li {
  counter-increment: rk;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--gold-line);
}
.ranklist li::before {
  content: counter(rk); width: 22px; flex: none; text-align: right;
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--faint);
}
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { display: block; color: var(--faint); font-size: 12px; }
.rank-elo { font-family: "JetBrains Mono", monospace; font-weight: 700; color: var(--gold); }

/* -------------------------------- Bàn cờ ------------------------------- */
.roomhead { flex: 1; min-width: 0; text-align: center; }
.roomhead b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roomhead .taglist { justify-content: center; margin-top: 3px; }

.strip {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; padding: 9px 14px;
  background: var(--ink-800); border-bottom: 1px solid var(--gold-line); color: var(--dim);
}
.strip .i { width: 15px; height: 15px; }
.strip-warn { background: rgba(193, 53, 42, .12); border-color: rgba(193, 53, 42, .35); color: var(--cinnabar-soft); }
.strip-offer {
  border: 1px solid var(--gold-line-2); border-radius: var(--r);
  background: rgba(201, 167, 92, .1); color: var(--gold-bright);
  margin-top: 10px; padding: 10px 12px;
}

.game { padding: 12px 12px 44px; max-width: 1220px; margin: 0 auto; }
.board-col { max-width: 560px; margin: 0 auto; }
.board-holder { display: flex; justify-content: center; margin: 9px 0; }
canvas#board { touch-action: none; border-radius: var(--r); box-shadow: var(--shadow); display: block; }

.plaque {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink-800); border: 1px solid var(--gold-line);
  border-radius: var(--r); padding: 9px 13px;
  transition: border-color .2s, background .2s;
}
.plaque.is-turn { border-color: var(--gold); background: rgba(201, 167, 92, .08); }
.plaque-id { min-width: 0; flex: 1; line-height: 1.3; }
.plaque-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plaque-tag { display: block; font-size: 11.5px; color: var(--faint); }
.plaque.is-offline .plaque-name { color: var(--dim); }

.disc {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 50%; font-family: "Noto Serif SC", serif; font-size: 21px;
  background: radial-gradient(circle at 35% 30%, #FBF3E2, #DFC9A2);
  border: 2px solid var(--gold-line-2); color: var(--faint);
}
.disc.r { color: var(--cinnabar); border-color: var(--cinnabar); }
.disc.b { color: #241F1A; border-color: #241F1A; }
.disc.sm { width: 26px; height: 26px; font-size: 15px; border-width: 1.5px; }
.disc.empty { background: var(--ink-600); color: var(--faint); border-style: dashed; }

.clock {
  font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 21px;
  padding: 3px 11px; border-radius: var(--r-sm);
  background: var(--ink-900); color: var(--dim); font-variant-numeric: tabular-nums;
}
.clock.is-run { color: var(--gold-bright); }
.clock.low { color: var(--cinnabar-soft); }

.actionbar { display: flex; gap: 8px; margin-top: 10px; }
.actionbar .btn { flex: 1; }

.rail {
  margin-top: 18px;
  background: linear-gradient(178deg, var(--ink-700), var(--ink-800));
  border: 1px solid var(--gold-line); border-radius: var(--r-lg); padding: 14px;
}
.railtabs {
  display: flex; gap: 2px; margin: -4px -4px 12px;
  border-bottom: 1px solid var(--gold-line);
  overflow-x: auto; scrollbar-width: none;
}
.railtabs::-webkit-scrollbar { display: none; }
.railtab {
  font: inherit; font-size: 13.5px; font-weight: 500;
  background: transparent; color: var(--dim);
  border: 0; border-bottom: 2px solid transparent;
  padding: 9px 11px; min-height: 42px; cursor: pointer; white-space: nowrap;
}
.railtab.is-on { color: var(--gold); border-bottom-color: var(--gold); }
.owner-only { display: none; }
body.is-owner .owner-only { display: inline-flex; }

.slots { display: grid; gap: 10px; margin: 14px 0; }
.slot { background: var(--ink-900); border: 1px solid var(--gold-line); border-radius: var(--r); padding: 12px; }
.slot-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; margin-bottom: 9px; }
.slot-head small { color: var(--faint); font-weight: 400; font-size: 12px; }
.quickrow { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quickrow .btn { flex: 1; min-width: 72px; }
.rowline { display: flex; gap: 8px; }
.rowline input { flex: 1; }
.rowline .btn { flex: none; }
.owner-actions { display: flex; gap: 8px; margin-top: 10px; }
.owner-actions .btn { flex: 1; }

.movelist { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 14px; }
.movelist li { display: flex; gap: 10px; padding: 5px 2px; border-bottom: 1px solid rgba(201, 167, 92, .07); }
.movelist .n { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--faint); width: 26px; flex: none; text-align: right; padding-top: 2px; }
.movelist .mv-r { color: var(--cinnabar-soft); }
.movelist .mv-b { color: #BCCAC1; }
.movelist .flip { color: var(--gold); }

.chatlog { max-height: 240px; overflow: auto; font-size: 14px; margin-bottom: 10px; }
.chatlog p { margin: 0 0 7px; }
.chatlog b { color: var(--gold); font-weight: 600; }
.chatlog .sys { color: var(--faint); font-style: italic; }
.chatform { display: flex; gap: 8px; }
.chatform input { flex: 1; min-height: 40px; }

.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--gold-line); }
.people li:last-child { border-bottom: 0; }
.people .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.taken { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; min-height: 32px; }
.taken i {
  font-family: "Noto Serif SC", serif; font-style: normal; font-size: 17px;
  width: 30px; height: 30px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #FBF3E2, #DFC9A2);
  border-radius: 50%; border: 1.5px solid currentColor;
}
.taken i.r { color: var(--cinnabar); }
.taken i.b { color: #241F1A; }

/* ------------------------------ Hộp thoại ------------------------------- */
.veil {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(7, 12, 10, .85); backdrop-filter: blur(5px);
}
.dialog {
  background: linear-gradient(178deg, var(--ink-700), var(--ink-800));
  border: 1px solid var(--gold-line-2); border-radius: 20px;
  padding: 28px 24px; text-align: center; width: 100%; max-width: 340px;
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 6px; font-size: 21px; font-weight: 600; }
.dialog p { color: var(--dim); margin: 0 0 18px; font-size: 14px; }
.dialog input { text-align: center; margin-bottom: 4px; }
.dialog-mark {
  width: 56px; height: 56px; margin: 0 auto 14px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--gold-line-2); background: var(--ink-600); color: var(--gold);
}
.dialog-mark .i { width: 24px; height: 24px; }
.dialog-btns { display: grid; gap: 8px; }
.dialog-wide { max-width: 400px; text-align: left; max-height: 88dvh; overflow-y: auto; }
.dialog-wide h2 { text-align: center; }
.dialog-wide p { text-align: center; }
.dialog-wide input { text-align: left; margin-bottom: 8px; }
.dialog-split { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--gold-line); }
.avpreview { display: grid; place-items: center; margin-bottom: 18px; }
.avgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avgrid button {
  font-family: "Noto Serif SC", serif; font-size: 19px; line-height: 1;
  aspect-ratio: 1; min-height: 42px; cursor: pointer;
  background: var(--ink-900); color: var(--dim);
  border: 1px solid var(--gold-line); border-radius: var(--r-sm);
}
.avgrid button.is-on { border-color: var(--gold); color: var(--gold-bright); background: rgba(201, 167, 92, .13); }
.avcolors { display: flex; gap: 8px; flex-wrap: wrap; }
.avcolors button {
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  font-family: "Noto Serif SC", serif; font-size: 18px; line-height: 1;
  border: 2px solid transparent;
}
.avcolors button.is-on { border-color: var(--gold-bright); }
.result-mark {
  width: 78px; height: 78px; margin: 0 auto 16px; display: grid; place-items: center;
  border-radius: 50%; border: 3px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #FBF3E2, #DFC9A2);
  font-family: "Noto Serif SC", serif; font-size: 40px; color: var(--cinnabar);
}

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: grid; gap: 8px; width: min(400px, calc(100% - 28px));
}
.toast {
  background: var(--ink-600); border: 1px solid var(--gold-line-2);
  border-left: 3px solid var(--gold); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 11px 14px; font-size: 14px; box-shadow: var(--shadow);
  animation: rise .2s ease; transition: opacity .3s;
}
.toast.error { border-left-color: var(--cinnabar); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------- Màn rộng ------------------------------- */
@media (max-width: 400px) {
  .brand-name { display: none; }
  .userchip-text b { max-width: 24vw; }
}
@media (min-width: 720px) {
  .lobby-grid { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }
}
@media (min-width: 1040px) {
  .game { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 26px; align-items: start; padding-top: 20px; }
  .rail { margin-top: 0; position: sticky; top: 78px; }
  .movelist { max-height: 360px; }
  .slots { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
