/* ================= Cờ Vua — MonBlock ================= */
:root {
  --bg: #0d1117;
  --panel: #151c26;
  --panel-2: #1b2431;
  --line: #2b3646;
  --txt: #e8eef6;
  --muted: #93a3b8;
  --accent: #ffd76a;
  --ok: #4fd18b;
  --coin: #ffcf4d;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Game page: no double-tap zoom (once zoomed, the board's touch-action:none would also block pinching back out) */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 10% -10%, #2a2318 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 0%, #1b2436 0%, transparent 55%),
    var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- thanh trên ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 6px;
}
.portal-link {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.portal-link:hover { color: var(--txt); }
.title { flex: 1; margin: 0; font-size: 21px; letter-spacing: .5px; color: var(--accent); }
.acct {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 40vw;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-weight: 700;
  font-size: 14px;
}
.acct span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px; }
.screen { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
h2 { font-size: 17px; margin: 18px 0 10px; }

/* ---------- trang chủ ---------- */
.me-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin: 6px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.me-av {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--panel-2);
  font-size: 34px;
}
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.me-info b { font-size: 18px; }
.me-info span { color: var(--muted); font-size: 14px; }
.xpbar { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 4px; max-width: 260px; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb347); }
.me-chips { display: flex; flex-direction: column; gap: 6px; font-size: 15px; text-align: right; }

.big {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0 0 10px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 18px;
  font-weight: 800;
  text-align: left;
  transition: transform .12s ease, border-color .12s ease;
}
.big small { margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.big:hover { transform: translateY(-2px); border-color: #46607d; }
.big-resume { border-color: var(--ok); background: linear-gradient(135deg, #17251d, var(--panel)); }
.big-ai { border-color: #7a5f22; background: linear-gradient(135deg, #2a2412, var(--panel)); }
.homegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.homegrid .small { position: relative; }
.small {
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-weight: 700;
  font-size: 14px;
}
.note { color: var(--muted); font-size: 13px; line-height: 1.5; }
.note a { color: var(--accent); }
.link { display: block; margin: 14px auto 0; border: 0; background: none; color: var(--muted); font-weight: 600; }

/* ---------- chọn mức ---------- */
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lv {
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: left;
}
.lv b { display: block; font-size: 17px; }
.lv span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.lv.active { border-color: var(--accent); background: #2a2412; }
.seg { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--panel); margin-bottom: 14px; }
.seg button { flex: 1; padding: 10px 6px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; }
.seg button.active { background: var(--panel-2); color: var(--txt); }

/* ---------- ván cờ ---------- */
.play { display: flex; gap: 20px; align-items: flex-start; justify-content: center; }
.board-col { width: min(94vw, calc(100dvh - 230px), 660px); min-width: 260px; }
.pbar { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 2px; font-weight: 700; }
.pname { white-space: nowrap; transition: color .2s; }
.pbar.turn .pname { color: var(--accent); }
.pbar.turn .pname::before { content: '● '; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.caps { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 20px; letter-spacing: -4px; }
.caps .pc { font-size: inherit; }
.caps em { font-style: normal; font-size: 13px; letter-spacing: 0; margin-left: 8px; color: var(--muted); }
.think { display: inline-flex; gap: 3px; }
.think i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce .9s infinite ease-in-out; }
.think i:nth-child(2) { animation-delay: .15s; }
.think i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-5px); opacity: 1; } }
.clock {
  min-width: 70px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font: 800 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  color: var(--muted);
}
.clock.run { background: #eef3f8; color: #0d1117; border-color: #eef3f8; }
.clock.run.low { background: #e5484d; color: #fff; border-color: #e5484d; animation: blink 1s infinite; }

.review-tag {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translateX(-50%);
  z-index: 7;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(13, 17, 23, .85);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.nav button { padding: 8px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 15px; }
.nav button:disabled { opacity: .35; cursor: default; }

.side { width: 290px; flex: none; }
.status { padding: 12px 14px; border-radius: 14px; background: var(--panel); font-weight: 800; margin-bottom: 10px; transition: background .2s; }
.status.check { background: #3a1f22; color: #ffb3a8; }
.status.over { background: #2a2412; color: var(--accent); }
.moves {
  height: 280px;
  overflow: auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.mv-row { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 4px; align-items: center; }
.mv-row > span:first-child { color: var(--muted); padding-left: 4px; }
.mv { padding: 3px 6px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-weight: 600; }
.mv:hover { background: var(--panel-2); }
.mv.cur { background: var(--accent); color: #1c1608; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tools button { padding: 11px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 700; font-size: 14px; }
.tools button:disabled { opacity: .45; cursor: default; }

/* tắt hiệu ứng (Tuỳ chỉnh) */
body.no-anim .piece { transition: none; }
body.no-anim .sq.check::before, body.no-anim .pbar.turn .pname::before { animation: none; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(var(--rot)); } }

/* ---------- tuỳ chỉnh ---------- */
.toggles { display: grid; gap: 8px; }
.tg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-weight: 700;
  cursor: pointer;
}
.tg input { display: none; }
.tg i { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--line); transition: background .2s; flex: none; }
.tg i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tg input:checked + i { background: var(--ok); }
.tg input:checked + i::after { transform: translateX(18px); }

/* ---------- xếp hạng + thống kê ---------- */
.rank { display: grid; gap: 6px; }
.rk { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); }
.rk.me { border: 1px solid var(--accent); }
.rk .n { width: 26px; color: var(--muted); font-weight: 800; }
.rk .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk .pt { color: var(--accent); font-weight: 800; }
.empty { color: var(--muted); padding: 10px 0; }
table.st { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 14px; overflow: hidden; }
.st th, .st td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.st th { color: var(--muted); font-weight: 600; font-size: 13px; }

/* ---------- hộp thoại ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 12, .66); }
.dialog {
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  animation: fade .18s ease;
}
.dialog h3 { margin: 0 0 10px; font-size: 20px; color: var(--accent); text-align: center; }
.dialog p { color: var(--muted); line-height: 1.5; text-align: center; margin: 6px 0; }
.dialog ul { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.dialog li { padding: 9px 12px; border-radius: 10px; background: var(--panel-2); font-weight: 700; }
.mbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mbtns button { flex: 1; min-width: 120px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 800; }
.mbtns button.pri { background: var(--accent); color: #1c1608; border-color: var(--accent); }
.promo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promo button { padding: 10px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--light); font-size: 44px; line-height: 1; }

.updatebar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2);
}
.updatebar button { padding: 8px 12px; border: 0; border-radius: 10px; background: var(--accent); color: #1c1608; font-weight: 800; }

@media (max-width: 860px) {
  .play { flex-direction: column; align-items: center; }
  .side { width: min(94vw, 660px); }
  .moves { height: auto; max-height: 132px; }
  .tools { grid-template-columns: repeat(4, 1fr); }
  .tools button { font-size: 12px; padding: 10px 2px; }
}
@media (max-width: 520px) {
  .title { font-size: 17px; }
  .acct { max-width: 34vw; }
}
.promo .pc { font-size: 44px; }
.rk .nm small { color: var(--muted); font-weight: 500; }

/* ---------- online ---------- */
.big-online { border-color: #2b6f8f; background: linear-gradient(135deg, #12263a, var(--panel)); }
.on-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.on-elo { color: var(--accent); font-weight: 800; }
.on-join { display: flex; gap: 8px; }
.on-join input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--txt);
  font: inherit;
  font-size: 18px;
  letter-spacing: 3px;
}
.on-join .small { white-space: nowrap; padding: 12px 16px; }
.on-wait { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); text-align: center; }
.on-code { font: 900 46px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 8px; color: var(--accent); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pname small { color: var(--muted); font-weight: 600; }
.net { font-size: 12px; font-weight: 700; color: #ffb3a8; white-space: nowrap; }

/* ================= cửa hàng, nhiệm vụ, biến thể ================= */
.muted { color: var(--muted); font-weight: 500; font-size: 13px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--muted); }
.coin-chip b { color: var(--coin); }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 99px; background: #e5484d; color: #fff; font-size: 12px; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg); animation: pop 1.6s ease-in-out infinite;
}
@keyframes pop { 50% { transform: scale(1.15); } }

.quest-strip {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 12px; padding: 10px 14px;
  border: 1px solid #5c4a1a; border-radius: 14px; background: linear-gradient(135deg, #2a2412, var(--panel)); text-align: left; font-weight: 700; font-size: 14px;
}
.qs-ico { font-size: 20px; }
.qs-txt { flex: 1; min-width: 0; }
.qs-bar { width: 70px; height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; flex: none; }
.qs-bar i { display: block; height: 100%; width: 0; background: var(--coin); transition: width .4s; }

/* biến thể */
.variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.variants.compact { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.vcard {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 2px solid var(--line);
  border-radius: 14px; background: var(--panel); text-align: left; transition: transform .12s, border-color .12s;
}
.vcard:hover { transform: translateY(-2px); }
.vcard .vi { font-size: 24px; line-height: 1.1; }
.vcard b { font-size: 14px; }
.vcard small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.vcard em { position: absolute; top: 8px; right: 8px; font-style: normal; font-size: 11px; color: var(--coin); }
.vcard.active { border-color: var(--accent); background: #2a2412; }
.variants.compact .vcard small { display: none; }
.vrules { margin: 8px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); color: var(--txt); font-size: 13px; line-height: 1.5; }
.vrules em { color: var(--coin); font-style: normal; font-weight: 700; }
.vtag {
  display: block; width: 100%; margin-bottom: 8px; padding: 8px 12px; border: 1px solid #5c4a1a; border-radius: 12px;
  background: #2a2412; color: var(--accent); font-weight: 800; text-align: left;
}
.vtag small { float: right; color: var(--muted); font-weight: 600; }
.chk { margin-left: 4px; color: #ff6b5b; font-size: 13px; letter-spacing: 1px; }
.chk i { font-style: normal; color: var(--line); }

.caps .pc.gl-emoji { display: inline; width: auto; height: auto; background: none; box-shadow: none; font-size: 15px; letter-spacing: 0; }

/* xu bay lên khi nhận */
.coinpop {
  position: fixed; z-index: 40; transform: translate(-50%, 0); pointer-events: none; color: var(--coin);
  font-size: 22px; font-weight: 900; text-shadow: 0 2px 8px rgba(0, 0, 0, .7); animation: coinup 1.3s ease-out forwards;
}
@keyframes coinup { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -80px) scale(1); } }

/* hộp thoại: dòng thưởng */
.dialog li.coin { color: var(--coin); background: #2e2610; }
.dialog li.sub { font-weight: 600; font-size: 13px; color: var(--muted); padding: 5px 12px; }
.dialog li.quest { color: #9fe3b8; background: #16261d; }
.promo.five { grid-template-columns: repeat(5, 1fr); }

/* cửa hàng */
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.big-coins { padding: 6px 14px; border-radius: 99px; background: var(--panel); border: 1px solid #5c4a1a; font-weight: 800; font-size: 17px; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 2px solid var(--line);
  border-radius: 14px; background: var(--panel); text-align: left; transition: transform .12s;
}
.item:hover { transform: translateY(-2px); }
.item.r-rare { border-color: #2c4f7d; }
.item.r-epic { border-color: #5a3d80; background: linear-gradient(160deg, #221a33, var(--panel) 60%); }
.item.r-legend { border-color: #8a6a1a; background: linear-gradient(160deg, #33280d, var(--panel) 60%); }
.item.active { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(79, 209, 139, .35); }
.item.locked .prev { filter: grayscale(.6) brightness(.7); }
.item b { font-size: 14px; }
.item .rar { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.item .act { margin-top: 4px; padding: 6px 8px; border-radius: 9px; background: var(--panel-2); font-size: 13px; font-weight: 800; text-align: center; }
.item .act.buy { background: #3a300f; color: var(--coin); }
.item.poor .act.buy { opacity: .6; }
.item.owned .act { color: var(--ok); }
.item.active .act { background: #17251d; }
.prev { display: grid; grid-template-columns: repeat(4, 1fr); aspect-ratio: 2; border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.prev.big { aspect-ratio: 1; width: min(240px, 70vw); margin: 0 auto 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.prev i { display: grid; place-items: center; font-style: normal; min-width: 0; }
.prev .pc { font-size: 24px; }
.prev.big .pc { font-size: 40px; }
.prev.icon { display: grid; place-items: center; grid-template-columns: 1fr; font-size: 38px; background: var(--panel-2); }
.prev.icon.big { width: 120px; font-size: 64px; }
.buyprev { display: flex; justify-content: center; }

/* nhiệm vụ */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 13px;
}
.day small { color: var(--muted); font-size: 11px; }
.day b { color: var(--coin); white-space: nowrap; }
.day em { font-style: normal; font-size: 11px; color: var(--muted); }
.day.today { border-color: var(--coin); background: #2e2610; }
.day.got { opacity: .55; }
.day.got i { position: absolute; top: 2px; right: 6px; font-style: normal; color: var(--ok); font-weight: 900; }
.days.mini { margin: 6px 0 10px; }
.days.mini .day { padding: 6px 0; }
.claim { padding: 9px 14px; border: 0; border-radius: 10px; background: var(--coin); color: #1c1608; font-weight: 900; animation: pop 1.6s ease-in-out infinite; }
.big-claim { display: block; width: 100%; margin-top: 10px; padding: 13px; font-size: 16px; animation: none; box-shadow: 0 0 18px rgba(255, 207, 77, .35); }
.qlist { display: grid; gap: 8px; }
.qrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.qrow.claimed { opacity: .55; }
.qi { font-size: 24px; width: 30px; text-align: center; flex: none; }
.qm { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.qm b { font-size: 14px; line-height: 1.35; }
.qm small { color: var(--muted); font-size: 12px; }
.qbar { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.qbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--coin), #ffb347); }
.qrow .done { color: var(--ok); font-weight: 900; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { padding: 6px 10px; border-radius: 99px; background: var(--panel); font-size: 13px; font-weight: 700; }
@media (max-width: 520px) {
  .homegrid { grid-template-columns: repeat(3, 1fr); }
  .days { gap: 3px; }
  .day b { font-size: 12px; }
}
