/* Cờ Vua — giao diện tối, bàn cờ to bên trái, bảng nước đi bên phải (học bố cục các trang cờ online) */
:root {
  --bg: #312e2b;
  --side: #262522;
  --panel: #262522;
  --panel2: #1f1e1b;
  --row: #2b2a27;
  --line: #3a3835;
  --text: #ffffff;
  --text2: #c3c2c1;
  --muted: #8b8987;
  --green: #7fa650;
  --green-hi: #95bb4a;
  --green-dk: #537a32;
  --red: #e04c3c;
  --gold: #f6c343;
  --light: #e8ebcf;
  --dark: #779a55;
  --hl: rgba(255, 255, 51, 0.5);
  --radius: 6px;
  --side-w: 168px;
  --panel-w: 400px;
  --bar-h: 48px;
  color-scheme: dark;
}
.theme-brown { --light: #f0d9b5; --dark: #b58863; }
.theme-blue { --light: #dee3e6; --dark: #8ca2ad; }
.theme-gray { --light: #d9d9d9; --dark: #8f8f8f; }
.theme-purple { --light: #efeaf5; --dark: #8f7aaf; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hide { display: none !important; }

/* ===== Khung trang ===== */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side {
  width: var(--side-w); flex: none; background: var(--side); display: flex; flex-direction: column;
  padding: 10px 0; position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.logo { display: flex; align-items: center; gap: 8px; padding: 6px 14px 14px; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -.3px; }
.logo i { width: 34px; height: 34px; flex: none; background: url(/favicon.svg) center/contain no-repeat; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 16px; border: 0; background: none;
  text-decoration: none; font-weight: 600; color: var(--text2); text-align: left; font-size: 15px;
}
.nav a:hover, .nav button:hover { background: #1c1b19; color: #fff; }
.nav a.on { color: #fff; background: #1c1b19; box-shadow: inset 3px 0 0 var(--green); }
.nav .ic { width: 22px; text-align: center; font-size: 18px; }
.side .foot { margin-top: auto; padding: 10px 16px; color: var(--muted); font-size: 12px; }

.top { display: none; }
main { flex: 1; min-width: 0; display: flex; justify-content: center; }

/* ===== Nút ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--radius);
  padding: 10px 16px; font-weight: 700; background: #3d3b38; color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
  min-height: 44px; text-decoration: none; user-select: none;
}
.btn:hover { background: #4a4845; }
.btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.green { background: var(--green); box-shadow: inset 0 -4px 0 var(--green-dk); }
.btn.green:hover { background: var(--green-hi); }
.btn.big { width: 100%; font-size: 22px; padding: 16px; min-height: 64px; border-radius: 10px; }
.btn.red { background: #a83a2f; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--text2); }
.btn.ghost:hover { background: #3a3835; color: #fff; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }

/* ===== Trang chủ ===== */
.home { width: 100%; max-width: 1180px; display: flex; gap: 28px; padding: 28px 24px; align-items: flex-start; justify-content: center; }
.home .hb { flex: 1 1 520px; max-width: 640px; }
.home .hb .cb { width: 100%; border-radius: 4px; box-shadow: 0 6px 30px rgba(0,0,0,.35); }
.home .hb h1 { font-size: 34px; line-height: 1.15; margin: 22px 0 6px; letter-spacing: -.5px; }
.home .hb p { color: var(--text2); margin: 0; }
.card { background: var(--panel); border-radius: 10px; overflow: hidden; box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.home .card { flex: 0 1 var(--panel-w); width: var(--panel-w); }
.tabs { display: flex; background: var(--panel2); }
.tabs button {
  flex: 1; border: 0; background: none; padding: 12px 6px 10px; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; border-bottom: 3px solid transparent; min-height: 56px;
}
.tabs button .ic { font-size: 20px; }
.tabs button.on { color: #fff; border-bottom-color: var(--green); background: var(--panel); }
.tabs button:hover { color: #fff; }
.cbody { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.lbl { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.inp {
  width: 100%; background: #1c1b19; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px;
  color: #fff; font-size: 16px; min-height: 44px; outline: none;
}
.inp:focus { border-color: var(--green); }
.inp.code { text-transform: uppercase; letter-spacing: 4px; font-weight: 800; text-align: center; font-size: 22px; }
.tcg { display: flex; flex-direction: column; gap: 8px; }
.tcg .cat { font-size: 13px; color: var(--text2); font-weight: 700; display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.tcg .row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chip {
  border: 1px solid transparent; background: #3a3835; border-radius: var(--radius); padding: 9px 4px; font-weight: 700; min-height: 44px;
  color: #fff;
}
.chip:hover { background: #474542; }
.chip.on { border-color: var(--green); background: #3e4a2f; box-shadow: inset 0 0 0 1px var(--green); }
.colors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.colors .chip { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; padding: 8px 4px; }
.colors .chip img, .colors .chip .rnd { width: 34px; height: 34px; }
.colors .chip .rnd { background: linear-gradient(90deg, #fff 50%, #222 50%); border-radius: 50%; border: 2px solid #777; }
.bots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.bot {
  border: 2px solid transparent; background: #3a3835; border-radius: 8px; padding: 6px 2px 5px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: #fff; min-height: 44px;
}
.bot .face { width: 44px; height: 44px; border-radius: 6px; display: grid; place-items: center; font-size: 28px; }
.bot .elo { color: var(--muted); font-weight: 600; font-size: 11px; }
.bot.on { border-color: var(--green); background: #3e4a2f; }
.botdesc { display: flex; gap: 12px; align-items: center; background: #1f1e1b; border-radius: 8px; padding: 10px; }
.botdesc .face { width: 54px; height: 54px; border-radius: 8px; display: grid; place-items: center; font-size: 34px; flex: none; }
.botdesc b { display: block; font-size: 16px; }
.botdesc span { color: var(--text2); font-size: 14px; }
.recent { display: flex; flex-direction: column; gap: 6px; }
.recent a { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; background: #1f1e1b; border-radius: var(--radius); text-decoration: none; min-height: 44px; align-items: center; }
.recent a:hover { background: #2e2c29; }
.recent small { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; }

/* ===== Màn chơi ===== */
.game {
  --bs: min(calc(100vw - var(--side-w) - var(--panel-w) - 72px), calc(100dvh - 2 * var(--bar-h) - 40px));
  display: flex; gap: 20px; padding: 14px 20px; align-items: flex-start; justify-content: center; width: 100%;
}
.bcol { width: var(--bs); flex: none; min-width: 280px; }
.bwrap { position: relative; width: 100%; aspect-ratio: 1; }
.pbar { display: flex; align-items: center; gap: 10px; height: var(--bar-h); padding: 4px 0; }
.av {
  width: 40px; height: 40px; border-radius: 4px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 19px; color: #fff;
  position: relative;
}
.av.bot { font-size: 26px; }
.av .dotol { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; background: #6a6865; border: 2px solid var(--bg); }
.av .dotol.on { background: #66c35b; }
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.pname { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: baseline; }
.pname small { color: var(--muted); font-weight: 600; font-size: 13px; }
.pname .warn { color: #f0a35b; font-size: 12px; font-weight: 600; }
.pname .think { color: var(--muted); font-weight: 500; font-size: 13px; font-style: italic; }
.caps { display: flex; align-items: center; height: 18px; min-width: 0; }
.caps img { width: 18px; height: 18px; margin-right: -7px; }
.caps img.gap { margin-left: 6px; }
.caps .adv { margin-left: 12px; font-size: 12px; color: var(--muted); font-weight: 700; }
.clock {
  flex: none; min-width: 108px; height: 40px; border-radius: 4px; background: #2b2926; color: #8b8987; font-weight: 700;
  font-size: 24px; display: flex; align-items: center; justify-content: flex-end; padding: 0 12px; gap: 6px; font-variant-numeric: tabular-nums;
}
.clock .ci { font-size: 14px; opacity: 0; }
.clock.run { background: #fff; color: #262421; }
.clock.run .ci { opacity: .8; animation: spin 2s linear infinite; display: inline-block; }
.clock.low { color: #fff; background: #c43d31; }
.clock.low.run { background: #e04c3c; }
.clock.idle { background: #262421; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Bàn cờ ===== */
.cb { position: relative; width: 100%; aspect-ratio: 1; user-select: none; -webkit-user-select: none; touch-action: none; border-radius: 3px; overflow: visible; }
.cb-sq, .cb-coords, .cb-hl, .cb-pcs, .cb-arr, .cb-dots, .cb-promo { position: absolute; inset: 0; }
.cb-sq {
  border-radius: 3px;
  background-color: var(--light);
  background-image: conic-gradient(var(--dark) 90deg, var(--light) 90deg 180deg, var(--dark) 180deg 270deg, var(--light) 270deg);
  background-size: 25% 25%;
}
.cb-coords span { position: absolute; font-weight: 700; font-size: max(10px, calc(var(--bs, 600px) * 0.024)); line-height: 1; pointer-events: none; }
.cb-coords .cr { left: 0.4%; padding-top: 0.5%; }
.cb-coords .cf { bottom: 0.5%; width: 12.5%; text-align: right; padding-right: 0.6%; }
.cb-coords .on-l { color: var(--dark); }
.cb-coords .on-d { color: var(--light); }
.hl { position: absolute; width: 12.5%; height: 12.5%; }
.hl.last, .hl.sel { background: var(--hl); }
.hl.pre { background: rgba(220, 60, 50, 0.55); }
.hl.mark { background: rgba(235, 97, 80, 0.8); }
.hl.goal { box-shadow: inset 0 0 0 calc(var(--bs, 600px) * 0.008) rgba(66, 140, 245, 0.95); background: radial-gradient(circle, rgba(66,140,245,.28) 0 30%, transparent 32%); }
.hl.chk { background: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(231, 0, 0, 1) 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%); }
.hl.hover { box-shadow: inset 0 0 0 calc(var(--bs, 600px) * 0.007) rgba(255, 255, 255, 0.75); }
.pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; background-size: cover; will-change: transform; pointer-events: none; }
.cb-pcs.anim .pc { transition: transform .17s cubic-bezier(.3,.7,.4,1); }
.pc.drag { z-index: 10; transition: none !important; transform-origin: center; scale: 1.12; filter: drop-shadow(0 6px 6px rgba(0,0,0,.35)); }
.cb-arr { pointer-events: none; width: 100%; height: 100%; z-index: 5; }
.cb-dots { pointer-events: none; z-index: 4; }
.dot { position: absolute; width: 12.5%; height: 12.5%; }
.dot::after { content: ''; position: absolute; inset: 34%; border-radius: 50%; background: rgba(0, 0, 0, 0.16); }
.dot.cap::after { inset: 0; background: none; border-radius: 50%; box-shadow: inset 0 0 0 calc(var(--bs, 600px) * 0.0095) rgba(0, 0, 0, 0.16); }
.dot.pre::after { background: rgba(60, 20, 20, 0.22); }
.cb-promo { display: none; z-index: 20; }
.cb-promo.on { display: block; }
.pr-shade { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.pr-col { position: absolute; width: 12.5%; display: flex; flex-direction: column; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.5); border-radius: 3px; overflow: hidden; }
.pr-p { width: 100%; aspect-ratio: 1; border: 0; background: #fff center/90% no-repeat; }
.pr-p:hover { background-color: #dfe8c9; }
.pr-x { border: 0; background: #f1f1f1; color: #666; height: calc(var(--bs, 600px) * 0.05); font-size: 14px; }

/* ===== Lớp phủ trên bàn (kết quả, chờ) ===== */
.ov { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; pointer-events: none; }
.ov > * { pointer-events: auto; }
.res {
  width: min(320px, 86%); background: var(--panel); border-radius: 12px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.6);
  animation: pop .25s ease-out; text-align: center;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.res-head { padding: 18px 14px 14px; background: #3a3835; position: relative; }
.res-head.win { background: linear-gradient(180deg, #6f9a43, #557a32); }
.res-head.lose { background: linear-gradient(180deg, #57534e, #403d39); }
.res-head.draw { background: linear-gradient(180deg, #6b6863, #4f4c48); }
.res-title { font-size: 26px; font-weight: 800; }
.res-sub { color: rgba(255,255,255,.85); font-size: 14px; margin-top: 2px; }
.res-x { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; background: none; color: #fff; font-size: 18px; opacity: .8; }
.res-vs { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 16px 10px 8px; }
.res-vs .pp { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 96px; font-weight: 700; font-size: 13px; }
.res-vs .pp span { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-vs .av { width: 56px; height: 56px; font-size: 26px; }
.res-vs .av.wn { box-shadow: 0 0 0 3px var(--green); }
.res-vs .sc { font-size: 22px; font-weight: 800; }
.res-btns { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 16px; }
.res-tally { color: var(--muted); font-size: 13px; padding-bottom: 4px; }
.conf { position: absolute; inset: 0; overflow: hidden; pointer-events: none !important; }
.conf i { position: absolute; top: -10px; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.4s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ===== Bảng bên phải ===== */
.panel {
  width: var(--panel-w); flex: none; background: var(--panel); border-radius: 8px; display: flex; flex-direction: column;
  height: calc(var(--bs) + 2 * var(--bar-h)); min-height: 420px; overflow: hidden;
}
.ptabs { display: flex; background: var(--panel2); flex: none; }
.ptabs button {
  flex: 1; border: 0; background: none; padding: 12px 6px; color: var(--muted); font-weight: 700; display: flex; gap: 6px;
  align-items: center; justify-content: center; border-bottom: 3px solid transparent; min-height: 48px;
}
.ptabs button.on { color: #fff; background: var(--panel); border-bottom-color: var(--green); }
.ptabs .badge { background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; }
.pbody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ginfo { padding: 10px 14px; color: var(--text2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; border-bottom: 1px solid var(--line); }
.ginfo b { color: #fff; }
.opening { padding: 6px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); min-height: 30px; }
.mlist { flex: 1; min-height: 0; overflow-y: auto; font-size: 15px; scrollbar-width: thin; }
.mrow { display: grid; grid-template-columns: 48px minmax(0, 1fr) minmax(0, 1fr); align-items: center; min-height: 30px; }
.mrow:nth-child(odd) { background: var(--row); }
.mrow .n { color: var(--muted); padding-left: 14px; font-size: 14px; }
.mv { border: 0; background: none; text-align: left; padding: 3px 8px; border-radius: 3px; font-weight: 600; color: var(--text2); display: inline-flex; align-items: center; gap: 1px; margin-right: 8px; min-height: 28px; white-space: nowrap; }
.mv:hover { background: #3a3835; color: #fff; }
.mv.cur { background: #48464a; color: #fff; box-shadow: inset 0 -2px 0 #8d8c8b; }
.mv img { width: 18px; height: 18px; margin-right: 1px; }
.mres { text-align: center; padding: 10px; font-weight: 800; color: #fff; }
.mres small { display: block; color: var(--muted); font-weight: 600; }
.notice { flex: none; }
.ask { margin: 8px 10px; background: #3a3835; border-radius: 8px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; animation: pop .2s; }
.ask b { font-size: 14px; }
.ask .bb { display: flex; gap: 6px; }
.pctl { display: flex; background: var(--panel2); flex: none; }
.pctl button { flex: 1; border: 0; background: none; color: var(--text2); font-size: 20px; min-height: 44px; display: grid; place-items: center; }
.pctl button:hover { color: #fff; background: #2b2a27; }
.pctl button:disabled { opacity: .3; }
.pact { display: flex; gap: 8px; padding: 10px; background: var(--panel2); flex: none; border-top: 1px solid #2c2b28; }
.pact .btn { flex: 1; font-size: 14px; padding: 8px; }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chatlog { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.chatlog .cm b { margin-right: 6px; }
.chatlog .sys { color: var(--muted); font-style: italic; font-size: 13px; }
.chatf { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chatf .inp { min-height: 40px; padding: 8px 10px; }
.wait { padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.wait h2 { margin: 0; font-size: 22px; }
.linkbox { display: flex; gap: 6px; }
.linkbox .inp { font-size: 14px; }
.linkbox .btn { white-space: nowrap; flex: none; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #555; border-top-color: var(--green); animation: spin 0.9s linear infinite; display: inline-block; vertical-align: middle; }
.sumrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #1f1e1b; padding: 10px 12px; border-radius: 8px; }
.sumrow span { color: var(--text2); white-space: nowrap; }
.invite { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.invite .av { margin: 0 auto; width: 64px; height: 64px; font-size: 30px; }
.invite h2 { font-size: 20px; }
.bigcode { font-size: 13px; color: var(--muted); }
.bigcode b { color: #fff; letter-spacing: 3px; font-size: 18px; }
.botcard { display: flex; gap: 10px; padding: 12px 14px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.botcard .face { width: 48px; height: 48px; border-radius: 6px; display: grid; place-items: center; font-size: 30px; flex: none; }
.bubble { background: #fff; color: #222; border-radius: 10px; padding: 8px 12px; font-size: 14px; position: relative; flex: 1; min-height: 38px; }
.bubble::before { content: ''; position: absolute; left: -7px; top: 14px; border: 7px solid transparent; border-left: 0; border-right-color: #fff; }

/* ===== Đấu đội ===== */
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.modes .chip { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; min-height: 48px; }
.modes .mi { font-size: 20px; }
.av.team { font-size: 24px; }
.av.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 4px; }
.av.sm .dotol { width: 10px; height: 10px; }
.mvr { font-size: 12px; color: var(--text2); margin-right: 10px; white-space: nowrap; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.mvr b { color: #fff; }
.squad { padding: 8px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sq-row { display: flex; gap: 4px 8px; align-items: baseline; flex-wrap: wrap; }
.sq-t { font-weight: 800; white-space: nowrap; }
.sq-t small { color: var(--muted); font-weight: 600; margin-left: 2px; }
.sq-m { color: var(--text2); display: flex; flex-wrap: wrap; gap: 2px 3px; align-items: baseline; }
.sq-m i { font-style: normal; color: var(--muted); font-size: 11px; }
.mem { padding: 1px 6px; border-radius: 4px; }
.mem.cur { background: var(--green); color: #fff; font-weight: 700; }
.mem.nx { box-shadow: inset 0 0 0 1px var(--green); color: #fff; }
.mem.off { opacity: .45; text-decoration: line-through; }
.mv .by { color: var(--muted); font-weight: 500; font-size: 11px; margin-left: 6px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.teams2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.tcol { background: #1f1e1b; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; border-top: 4px solid var(--tc); min-width: 0; }
.thead { font-weight: 800; font-size: 15px; display: flex; flex-direction: column; }
.thead small { color: var(--muted); font-weight: 600; font-size: 12px; }
.tmem { display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
.mem-row { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.mem-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-row.off { opacity: .5; }
.tcol .btn { margin-top: auto; }
.hostbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.hostbtns .btn { flex: 1; }
.ask.mine { background: #3e4a2f; box-shadow: inset 0 0 0 1px var(--green); }
.chs { background: #1c1b19; border: 1px solid var(--line); border-radius: 6px; color: #fff; padding: 0 4px; min-height: 40px; max-width: 120px; flex: none; }
.goalc { margin: 8px 10px 0; background: #1f2a3a; border: 1px solid #2f4a70; border-radius: 8px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.goalc .gi { font-size: 20px; }
.goalc .gx { flex: 1; min-width: 0; }
.goalc .gl { font-size: 11px; color: #8fb2e6; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.goalc .gt { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.goalc .gt.empty { color: var(--muted); font-weight: 500; }
.sync { color: #8fb2e6; font-weight: 700; white-space: nowrap; }
.ask.sug { background: #1f2a3a; box-shadow: inset 0 0 0 1px #2f4a70; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .chip { padding: 6px 10px; font-size: 14px; min-height: 40px; }
.res-sync { color: #8fb2e6; font-size: 13px; font-weight: 700; padding-bottom: 4px; }
.cm .tg { font-size: 11px; background: #3e4a2f; color: #cfe3b5; border-radius: 4px; padding: 0 5px; margin-right: 6px; }

/* ===== Hộp thoại + thông báo ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 16px; }
.mbox { width: min(420px, 100%); background: var(--panel); border-radius: 12px; overflow: hidden; max-height: 90vh; display: flex; flex-direction: column; }
.mhead { padding: 14px 16px; font-weight: 800; font-size: 18px; display: flex; justify-content: space-between; align-items: center; background: var(--panel2); }
.mhead button { border: 0; background: none; color: #fff; font-size: 20px; width: 44px; height: 44px; }
.mbody { padding: 16px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.sw { border: 2px solid transparent; border-radius: 6px; aspect-ratio: 1; padding: 0; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; min-height: 44px; }
.sw.on { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
.sw i:nth-child(1), .sw i:nth-child(4) { background: var(--light); }
.sw i:nth-child(2), .sw i:nth-child(3) { background: var(--dark); }
.tg { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.tg input { appearance: none; width: 46px; height: 26px; border-radius: 13px; background: #555; position: relative; flex: none; cursor: pointer; transition: background .15s; }
.tg input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.tg input:checked { background: var(--green); }
.tg input:checked::after { left: 23px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 8px;
  z-index: 200; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pop .2s; max-width: calc(100vw - 32px); text-align: center;
}
.banner { position: fixed; top: 0; left: 0; right: 0; background: #b5762a; color: #fff; text-align: center; padding: 6px; font-size: 14px; z-index: 150; font-weight: 600; }
.center-msg { padding: 60px 20px; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.center-msg h2 { margin: 0; }
.rules { color: var(--text2); font-size: 14px; }
.rules h3 { color: #fff; margin: 14px 0 6px; font-size: 15px; }
.rules p, .rules li { margin: 4px 0; }

/* ===== Máy tính bảng / điện thoại ===== */
@media (max-width: 1100px) {
  :root { --panel-w: 330px; --side-w: 64px; }
  .side .logo span, .nav .tx, .side .foot { display: none; }
  .side .logo { padding: 6px 15px 14px; }
  .nav a, .nav button { justify-content: center; padding: 12px 0; }
}
@media (max-width: 860px) {
  :root { --bar-h: 46px; }
  .shell { flex-direction: column; }
  .side { display: none; }
  .top {
    display: flex; align-items: center; gap: 4px; height: 48px; padding: 0 8px; background: var(--side); position: sticky; top: 0; z-index: 50;
  }
  .top .logo { padding: 0 6px; font-size: 18px; }
  .top .logo i { width: 30px; height: 30px; }
  .top .sp { flex: 1; }
  .top .ib { border: 0; background: none; color: var(--text2); min-width: 44px; height: 44px; display: grid; place-items: center; font-size: 20px; text-decoration: none; border-radius: 6px; }
  .top .ib.on { color: #fff; background: #1c1b19; }
  .home { flex-direction: column; padding: 12px; gap: 14px; align-items: stretch; }
  .home .hb { display: none; }
  .home .card { width: 100%; flex: none; }
  .game { --bs: min(100vw, max(260px, calc(100dvh - 48px - 2 * var(--bar-h) - 60px))); flex-direction: column; align-items: center; padding: 0 0 12px; gap: 6px; }
  .bcol { width: var(--bs); min-width: 0; }
  .pbar { padding: 3px 8px; }
  .av { width: 36px; height: 36px; font-size: 17px; }
  .clock { min-width: 92px; height: 36px; font-size: 21px; }
  .panel { width: 100%; max-width: 640px; height: auto; min-height: 0; border-radius: 0; background: transparent; }
  .game.waiting .panel { order: -1; }
  .panel .ptabs { display: none; }
  .panel .pbody, .panel .tab-moves { display: contents; }
  .panel .tab-chat { display: flex !important; order: 6; border-top: 1px solid var(--line); margin-top: 6px; }
  .panel .mlist { order: 0; }
  .panel .notice { order: 1; }
  .panel .pact { order: 2; }
  .panel .pctl { order: 3; }
  .panel .botcard { order: 4; border: 0; }
  .panel .ginfo { order: 5; }
  .panel .goalbox { order: 1; }
  .panel .squad { order: 1; border: 0; padding: 4px 10px; }
  .mv .by { display: none; }
  .mlist { display: flex; overflow-x: auto; overflow-y: hidden; white-space: nowrap; padding: 4px 6px; flex: none; scrollbar-width: none; }
  .mlist::-webkit-scrollbar { display: none; }
  .mrow { display: inline-flex; background: none !important; min-height: 34px; }
  .mrow .n { padding-left: 6px; padding-right: 2px; }
  .mres { padding: 4px 10px; }
  .mres small { display: inline; margin-left: 4px; }
  .ginfo, .opening { border: 0; }
  .chatlog { max-height: 220px; min-height: 120px; }
  .wait { padding: 14px 12px; }
  .pact { background: transparent; border: 0; padding: 6px 10px; }
  .pctl { background: transparent; }
}
/* Điện thoại nằm ngang: bàn bên trái, bảng bên phải, thanh trên không dính */
@media (max-width: 860px) and (orientation: landscape) and (max-height: 520px) {
  .top { position: static; }
  .game { --bs: min(calc(100dvh - 2 * var(--bar-h) - 8px), calc(100vw - 330px)); flex-direction: row; align-items: flex-start; padding: 4px 8px; gap: 10px; }
  .panel { width: auto; flex: 1; min-width: 0; height: calc(var(--bs) + 2 * var(--bar-h)); overflow-y: auto; }
  .chatlog { max-height: 120px; min-height: 60px; }
}
@media (max-width: 380px) {
  .clock { min-width: 80px; font-size: 19px; padding: 0 8px; }
  .bots { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .bot .face { width: 38px; height: 38px; font-size: 24px; }
}
@media (pointer: coarse) {
  .pc.drag { scale: 1.6; translate: 0 -30%; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-pcs.anim .pc { transition: none; }
  .res, .ask, .toast { animation: none; }
}
