/* ChessNexa — design tokens + components */
[hidden] { display: none !important; }
:root {
  --c-primary: #17675a; --c-primary-2: #0f4d43; --c-on-primary: #ffffff;
  --c-accent: #f0b43c; --c-danger: #d64545; --c-success: #2e9d5b; --c-info: #2c6fb3;
  --c-bg: #f2f6f4; --c-surface: #ffffff; --c-card: #dcece6; --c-card-2: #e9f3ef; --c-line: #cfdcd7;
  --c-text: #17231f; --c-text-2: #55675f; --c-text-3: #8a9a93; --c-shadow: rgba(16, 48, 40, .16);
  --c-overlay: rgba(10, 20, 18, .55); --c-ad: #e7ece9;
  --sq-light: #eaf1f8; --sq-dark: #8fb0cf; --sq-last: rgba(255, 214, 64, .55); --sq-sel: rgba(23, 103, 90, .45);
  --sq-check: rgba(214, 69, 69, .85); --sq-premove: rgba(232, 92, 92, .5); --sq-hint: rgba(44, 111, 179, .55);
  --r-s: 10px; --r-m: 16px; --r-l: 24px; --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --fs-xs: 12px; --fs-s: 14px; --fs-m: 16px; --fs-l: 19px; --fs-xl: 24px; --fs-xxl: 34px;
  --fw-m: 500; --fw-b: 700; --fw-x: 800;
  --tap: 48px; --ad-h: 56px; --bar-h: 60px; --t-fast: .15s; --t-med: .25s;
  --font: "Inter", "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", system-ui, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}
[data-theme="dark"] {
  --c-primary: #3fae98; --c-primary-2: #2b8f7c; --c-on-primary: #08130f;
  --c-bg: #0f1513; --c-surface: #18211e; --c-card: #1e2c27; --c-card-2: #22312c; --c-line: #2c3c36;
  --c-text: #e6f0ec; --c-text-2: #a8bbb3; --c-text-3: #6e8179; --c-shadow: rgba(0, 0, 0, .45); --c-ad: #1b2421;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--c-bg); color: var(--c-text); font-family: var(--font); font-size: var(--fs-m); }
body { overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--c-text); background: var(--c-surface); border: 1.5px solid var(--c-line); border-radius: var(--r-s); padding: var(--sp-3); width: 100%; }
a { color: var(--c-primary); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 24px; height: 24px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.fill { fill: currentColor; stroke: none; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#screens { flex: 1; position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow-y: auto; display: none; flex-direction: column; padding-bottom: var(--sp-6); }
.screen.active { display: flex; animation: fade var(--t-med); }
@keyframes fade { from { opacity: .3; transform: translateY(6px) } to { opacity: 1; transform: none } }
.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 var(--sp-4); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--sp-2); height: var(--bar-h); padding: 0 var(--sp-2); background: var(--c-card-2); box-shadow: 0 2px 6px var(--c-shadow); }
.topbar h1 { font-size: var(--fs-l); margin: 0; display: flex; align-items: center; gap: var(--sp-2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: var(--r-pill); display: grid; place-items: center; flex: none; }
.icon-btn:active { background: var(--c-card); }

/* home */
.home-head { display: flex; justify-content: space-between; align-items: flex-start; padding: var(--sp-4) var(--sp-4) 0; }
.chip-btn { width: var(--tap); height: var(--tap); border-radius: var(--r-m); background: var(--c-card); display: grid; place-items: center; color: var(--c-primary); position: relative; }
.chip-btn .dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--c-danger); }
.brand { text-align: center; margin-top: -8px; }
.brand .logo { width: 92px; height: 92px; }
.brand h2 { font-family: var(--font-display); font-size: 44px; letter-spacing: 1px; margin: var(--sp-1) 0 0; font-weight: 900; }
.brand h2 span { color: var(--c-primary); }
.brand p { margin: 0; color: var(--c-text-2); font-size: var(--fs-l); }
.hero-board { width: min(78vw, 360px); aspect-ratio: 1; margin: var(--sp-4) auto 0; display: grid; grid-template-columns: repeat(8, 1fr);
  -webkit-mask-image: radial-gradient(circle, #000 35%, transparent 72%); mask-image: radial-gradient(circle, #000 35%, transparent 72%); opacity: .9; }
.hero-board div { background: var(--sq-light); display: grid; place-items: center; }
.hero-board div.d { background: color-mix(in srgb, var(--sq-dark) 45%, var(--sq-light)); }
.hero-board img { width: 82%; }
.stats-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.stats-row .stat { flex: 1; text-align: center; color: var(--c-text-2); font-size: var(--fs-s); }
.stats-row b { color: var(--c-primary); font-size: var(--fs-l); }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4); }
.menu-card { min-height: 84px; border-radius: var(--r-l); background: var(--c-card); box-shadow: 0 4px 10px var(--c-shadow); display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); text-align: left; font-size: var(--fs-l); line-height: 1.2; color: var(--c-text); position: relative; }
.menu-card .icon { color: var(--c-primary); width: 30px; height: 30px; }
.menu-card.wide { grid-column: 1 / -1; width: 74%; justify-self: center; }
.menu-card small { display: block; color: var(--c-text-2); font-size: var(--fs-s); margin-top: 2px; }
.menu-card .mascot { margin-left: auto; font-size: 38px; }
.menu-card.solid { background: var(--c-primary); color: var(--c-on-primary); min-height: 70px; }
.menu-card.solid .icon { color: var(--c-on-primary); }
.menu-card:active { transform: scale(.98); }
.menu-card .badge-free { position: absolute; top: 8px; right: 12px; font-size: var(--fs-xs); color: var(--c-text-2); }

/* buttons */
.btn { min-height: var(--tap); padding: 0 var(--sp-5); border-radius: var(--r-pill); background: var(--c-primary); color: var(--c-on-primary); font-weight: var(--fw-b); font-size: var(--fs-m); display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--c-card); color: var(--c-text); }
.btn.danger { background: var(--c-danger); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.link-btn { color: var(--c-primary); font-weight: var(--fw-b); padding: var(--sp-3); }

/* settings */
.sec-title { color: var(--c-primary); font-weight: var(--fw-b); font-size: var(--fs-l); padding: var(--sp-6) 0 var(--sp-2); border-bottom: 1.5px solid var(--c-line); margin-bottom: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-4); min-height: 64px; padding: var(--sp-2) 0; width: 100%; text-align: left; font-size: var(--fs-l); }
.row .icon { color: var(--c-primary); width: 28px; height: 28px; }
.row .lbl { flex: 1; }
.row .lbl small { display: block; color: var(--c-text-3); font-size: var(--fs-m); }
.row.disabled { opacity: .45; pointer-events: none; }
.row .thumb { width: 28px; height: 28px; }
.switch { position: relative; width: 60px; height: 34px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--c-card); border: 2px solid var(--c-text-3); transition: var(--t-fast); }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 4px; top: 4px; border-radius: 50%; background: var(--c-text-3); transition: var(--t-fast); }
.switch input:checked + span { background: var(--c-primary); border-color: var(--c-primary); }
.switch input:checked + span::after { left: 30px; background: #fff; width: 24px; height: 24px; top: 3px; }
.info-dot { color: var(--c-info); }

/* premium card */
.premium { background: var(--c-surface); border-radius: var(--r-m); padding: var(--sp-5); box-shadow: 0 4px 14px var(--c-shadow); margin: var(--sp-3) var(--sp-2); }
.pill-note { display: block; width: fit-content; margin: 0 auto var(--sp-3); background: color-mix(in srgb, var(--c-success) 16%, transparent); color: var(--c-success); font-weight: var(--fw-b); padding: var(--sp-2) var(--sp-5); border-radius: var(--r-pill); }
.feat { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-2) 0; }
.feat .ic { width: 64px; height: 64px; border-radius: var(--r-m); background: var(--c-card); display: grid; place-items: center; color: var(--c-primary); flex: none; }
.feat .ic .icon { width: 32px; height: 32px; }
.feat b { display: block; font-size: var(--fs-l); }
.feat small { color: var(--c-text-2); font-size: var(--fs-m); }
.feat .ok { margin-left: auto; color: var(--c-success); }
.price { display: block; width: fit-content; margin: var(--sp-4) auto; background: var(--c-card); color: var(--c-primary); font-weight: var(--fw-x); font-size: var(--fs-xl); padding: var(--sp-2) var(--sp-8); border-radius: var(--r-pill); }
.profile-card { display: flex; gap: var(--sp-5); align-items: center; }
.avatar { width: 88px; height: 88px; border-radius: 50%; background: var(--c-card); display: grid; place-items: center; font-size: 46px; overflow: hidden; flex: none; box-shadow: 0 2px 8px var(--c-shadow); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 40px; height: 40px; font-size: 22px; box-shadow: none; }
.profile-card h3 { margin: 0; font-size: var(--fs-xl); word-break: break-all; }
.profile-card p { margin: var(--sp-1) 0; font-size: var(--fs-l); }

/* board */
.board-wrap { width: min(100vw, calc(100vh - 330px), 560px); min-width: 280px; margin: 0 auto; position: relative; touch-action: none; }
.board { position: relative; width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); border-radius: 4px; overflow: hidden; box-shadow: 0 3px 12px var(--c-shadow); }
.sq { position: relative; background: var(--sq-light); }
.sq.d { background: var(--sq-dark); }
.sq.last::before, .sq.sel::before, .sq.pre::before, .sq.hint::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: var(--sq-last); }
.sq.sel::before { background: var(--sq-sel); }
.sq.pre::before { background: var(--sq-premove); }
.sq.hint::before { background: var(--sq-hint); }
.sq.check { background-image: radial-gradient(circle, var(--sq-check) 0%, rgba(214, 69, 69, .5) 45%, transparent 72%); }
.sq .dot { position: absolute; left: 50%; top: 50%; width: 28%; height: 28%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(20, 40, 35, .28); pointer-events: none; }
.sq .ring { position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(20, 40, 35, .28); pointer-events: none; }
.sq .cf, .sq .cr { position: absolute; font-size: clamp(9px, 2.6vw, 13px); font-weight: var(--fw-b); pointer-events: none; opacity: .85; }
.sq .cf { right: 3px; bottom: 1px; } .sq .cr { left: 3px; top: 1px; }
.sq.d .cf, .sq.d .cr { color: var(--sq-light); } .sq:not(.d) .cf, .sq:not(.d) .cr { color: var(--sq-dark); }
.pc { position: absolute; width: 12.5%; height: 12.5%; background-size: 100% 100%; pointer-events: none; z-index: 2; will-change: transform; }
.pc.anim { transition: transform .18s ease-out; }
.pc.drag { z-index: 10; transition: none; transform-origin: center; }
.board.flipped { }
.promo-pick { display: flex; gap: var(--sp-2); justify-content: center; }
.promo-pick button { width: 72px; height: 72px; border-radius: var(--r-m); background: var(--c-card); }
.promo-pick img { width: 90%; }

/* game */
.player-bar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); max-width: 560px; margin: 0 auto; width: 100%; }
.player-bar .nm { flex: 1; min-width: 0; }
.player-bar .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .nm small { color: var(--c-text-2); }
.caps { display: flex; flex-wrap: wrap; height: 18px; overflow: hidden; }
.caps img { width: 18px; height: 18px; margin-right: -5px; }
.clock { font-variant-numeric: tabular-nums; font-weight: var(--fw-x); font-size: var(--fs-xl); background: var(--c-card); padding: var(--sp-1) var(--sp-3); border-radius: var(--r-s); min-width: 92px; text-align: center; }
.clock.run { background: var(--c-primary); color: var(--c-on-primary); }
.clock.low { background: var(--c-danger); color: #fff; }
.opening { text-align: center; color: var(--c-text-2); font-size: var(--fs-s); min-height: 20px; padding: var(--sp-1) var(--sp-4); }
.moves { display: flex; gap: var(--sp-1); overflow-x: auto; padding: var(--sp-2) var(--sp-3); max-width: 560px; margin: 0 auto; width: 100%; scrollbar-width: none; min-height: 40px; }
.moves button { flex: none; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-s); font-size: var(--fs-s); }
.moves button.cur { background: var(--c-primary); color: var(--c-on-primary); }
.moves .no { color: var(--c-text-3); font-size: var(--fs-s); padding: var(--sp-1) 0 0 var(--sp-1); flex: none; }
.moves .cls { font-weight: var(--fw-x); margin-left: 2px; }
.actions { display: flex; justify-content: space-around; max-width: 560px; margin: var(--sp-2) auto 0; width: 100%; padding: 0 var(--sp-2); }
.act { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: var(--fs-xs); color: var(--c-text-2); min-width: 60px; min-height: var(--tap); padding: var(--sp-1); border-radius: var(--r-s); }
.act .icon { color: var(--c-primary); }
.act:disabled { opacity: .35; }
.banner-msg { max-width: 560px; margin: var(--sp-2) auto; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-m); background: var(--c-card); text-align: center; font-weight: var(--fw-m); width: calc(100% - 2 * var(--sp-4)); }
.banner-msg.good { background: color-mix(in srgb, var(--c-success) 20%, var(--c-card)); }
.banner-msg.bad { background: color-mix(in srgb, var(--c-danger) 18%, var(--c-card)); }
.evalbar { height: 8px; background: #333; border-radius: 4px; overflow: hidden; max-width: 560px; margin: 0 auto; width: calc(100% - 24px); }
.evalbar i { display: block; height: 100%; background: #f4f4f4; width: 50%; transition: width var(--t-med); }
.analysis-sum { display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; font-size: var(--fs-s); padding: var(--sp-2); }
.analysis-sum span { background: var(--c-card); padding: 2px var(--sp-2); border-radius: var(--r-pill); }
.c-best { color: var(--c-success); } .c-good { color: var(--c-info); } .c-inacc { color: #c99a1e; } .c-mist { color: #e07b28; } .c-blun { color: var(--c-danger); }

/* chat */
.chat { position: fixed; right: var(--sp-3); bottom: calc(var(--ad-h) + var(--sp-3)); width: min(92vw, 360px); max-height: 50vh; background: var(--c-surface); border-radius: var(--r-m); box-shadow: 0 8px 30px var(--c-shadow); display: none; flex-direction: column; z-index: 30; }
.chat.open { display: flex; }
.chat .log { flex: 1; overflow-y: auto; padding: var(--sp-3); font-size: var(--fs-s); min-height: 120px; }
.chat .log p { margin: 0 0 var(--sp-2); user-select: text; }
.chat .quick { display: flex; gap: var(--sp-1); flex-wrap: wrap; padding: 0 var(--sp-2); }
.chat .quick button { font-size: var(--fs-xs); background: var(--c-card); padding: var(--sp-1) var(--sp-2); border-radius: var(--r-pill); }
.chat form { display: flex; gap: var(--sp-2); padding: var(--sp-2); }

/* lists */
.list-card { background: var(--c-surface); border-radius: var(--r-m); box-shadow: 0 2px 8px var(--c-shadow); margin: var(--sp-3) 0; overflow: hidden; }
.li { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-line); width: 100%; text-align: left; min-height: 56px; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .grow b, .li .grow small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li small { color: var(--c-text-2); }
.li .rk { width: 32px; font-weight: var(--fw-x); color: var(--c-text-2); text-align: center; }
.li.me { background: color-mix(in srgb, var(--c-primary) 12%, transparent); }
.li .done { color: var(--c-success); }
.li .lock { color: var(--c-text-3); }
.tabs { display: flex; background: var(--c-card); border-radius: var(--r-pill); padding: 4px; margin: var(--sp-4) 0; }
.tabs button { flex: 1; min-height: 40px; border-radius: var(--r-pill); font-weight: var(--fw-b); color: var(--c-text-2); }
.tabs button.on { background: var(--c-surface); color: var(--c-primary); box-shadow: 0 1px 4px var(--c-shadow); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.kpi { background: var(--c-surface); border-radius: var(--r-m); padding: var(--sp-3); text-align: center; box-shadow: 0 2px 6px var(--c-shadow); }
.kpi b { display: block; font-size: var(--fs-xl); color: var(--c-primary); }
.kpi small { color: var(--c-text-2); font-size: var(--fs-xs); }
.empty { text-align: center; color: var(--c-text-2); padding: var(--sp-8) var(--sp-4); }
.empty .icon { width: 48px; height: 48px; color: var(--c-text-3); }
.skel { background: linear-gradient(90deg, var(--c-card) 25%, var(--c-card-2) 50%, var(--c-card) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-s); height: 18px; margin: var(--sp-2) 0; }
@keyframes sk { to { background-position: -200% 0 } }

/* modal / sheet */
.modal-bg { position: fixed; inset: 0; background: var(--c-overlay); z-index: 50; display: none; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal-bg.open { display: flex; animation: fade var(--t-fast); }
.modal { background: var(--c-surface); border-radius: var(--r-l); width: min(100%, 460px); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal header { display: flex; align-items: center; padding: var(--sp-4) var(--sp-4) var(--sp-2) var(--sp-6); }
.modal header h3 { flex: 1; margin: 0; font-size: var(--fs-xl); text-align: center; padding-left: var(--tap); }
.modal .body { padding: var(--sp-2) var(--sp-6) var(--sp-4); overflow-y: auto; user-select: text; }
.modal footer { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-6) var(--sp-5); justify-content: center; flex-wrap: wrap; }
.set-opt { width: 100%; border-radius: var(--r-m); background: var(--c-card-2); margin-bottom: var(--sp-3); padding: var(--sp-2); border: 3px solid transparent; }
.set-opt.on { border-color: var(--c-primary); }
.set-opt b { display: block; margin-bottom: var(--sp-1); }
.set-opt .prev { display: flex; justify-content: space-around; }
.set-opt img { width: 15%; }
.board-opt { display: inline-grid; grid-template-columns: repeat(4, 1fr); width: 30%; aspect-ratio: 1; margin: 1.5%; border-radius: var(--r-s); overflow: hidden; border: 3px solid transparent; vertical-align: top; }
.board-opt.on { border-color: var(--c-primary); }
.choice { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.choice button { flex: 1; min-width: 70px; min-height: var(--tap); border-radius: var(--r-m); background: var(--c-card-2); font-weight: var(--fw-b); border: 2px solid transparent; padding: 0 var(--sp-2); }
.choice button.on { border-color: var(--c-primary); background: var(--c-card); color: var(--c-primary); }
.field { margin: var(--sp-3) 0; }
.field label { display: block; font-weight: var(--fw-b); margin-bottom: var(--sp-1); font-size: var(--fs-s); }
.consent { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--fs-s); margin: var(--sp-3) 0; line-height: 1.45; }
.consent input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--c-primary); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--sp-2); }
.avatars button { aspect-ratio: 1; font-size: 26px; border-radius: 50%; background: var(--c-card-2); border: 3px solid transparent; overflow: hidden; padding: 0; }
.avatars button.on { border-color: var(--c-primary); }
.avatars img { width: 100%; height: 100%; object-fit: cover; }
.legal-frame { width: 100%; height: 62vh; border: 0; background: #fff; border-radius: var(--r-s); }
.level-val { text-align: center; font-size: var(--fs-xl); font-weight: var(--fw-x); color: var(--c-primary); }
input[type=range] { padding: 0; accent-color: var(--c-primary); border: 0; background: none; }
.result-big { text-align: center; font-size: var(--fs-xxl); font-weight: var(--fw-x); margin: var(--sp-2) 0; }
.result-sub { text-align: center; color: var(--c-text-2); }
.delta { text-align: center; font-weight: var(--fw-b); font-size: var(--fs-l); margin-top: var(--sp-2); }
.delta.up { color: var(--c-success); } .delta.down { color: var(--c-danger); }
.code-box { font-size: 38px; letter-spacing: 8px; font-weight: var(--fw-x); text-align: center; color: var(--c-primary); margin: var(--sp-3); user-select: text; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--c-card); border-top-color: var(--c-primary); animation: spin 1s linear infinite; margin: var(--sp-4) auto; }
@keyframes spin { to { transform: rotate(360deg) } }

/* toast + ad */
#toast { position: fixed; left: 50%; bottom: calc(var(--ad-h) + 24px); transform: translateX(-50%) translateY(20px); background: #222c29; color: #fff; padding: var(--sp-3) var(--sp-5); border-radius: var(--r-pill); opacity: 0; transition: var(--t-med); z-index: 90; pointer-events: none; max-width: 90vw; text-align: center; font-size: var(--fs-s); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#adbar { height: var(--ad-h); flex: none; background: var(--c-ad); border-top: 1px solid var(--c-line); display: flex; align-items: center; justify-content: center; gap: var(--sp-3); font-size: var(--fs-s); color: var(--c-text-2); padding: 0 var(--sp-3); }
#adbar.hidden { display: none; }
#adbar .ad-tag { font-size: 10px; border: 1px solid var(--c-text-3); border-radius: 3px; padding: 0 3px; }
#adbar.native { display: none; }
.legal-page { padding: var(--sp-4); line-height: 1.6; user-select: text; }
@media (min-width: 700px) { .menu-card { min-height: 96px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 3D wooden table view */
.layer { position: absolute; inset: 0; pointer-events: none; }
.pc-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; background: center bottom / contain no-repeat; filter: drop-shadow(0 8px 8px rgba(0,0,0,.35)); }
.sq.over::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .7); }
.board.wood .sq { background-image: repeating-linear-gradient(92deg, rgba(90, 60, 30, .08) 0 2px, transparent 2px 6px, rgba(255, 255, 255, .06) 6px 7px, transparent 7px 11px); }
.board.wood .sq.d { background-image: repeating-linear-gradient(88deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 5px, rgba(0, 0, 0, .12) 5px 7px, transparent 7px 10px); }
.board-wrap.v3d { --tilt: 38deg; perspective: 1000px; perspective-origin: 50% -10%; width: min(100vw, calc((100vh - 300px) * 1.25), 580px); padding: 2% 3% 0; }
.v3d .board { transform: rotateX(var(--tilt)); transform-origin: 50% 100%; transform-style: preserve-3d; overflow: visible; margin-top: -12%;
  border: clamp(8px, 2.4vw, 16px) solid; border-color: #9b7550 #6c4c2e #4b3320 #6c4c2e; border-radius: 6px;
  box-shadow: 0 18px 0 -2px #3e2a19, 0 34px 40px rgba(0, 0, 0, .45); background: #3e2a19; }
.v3d .layer { transform-style: preserve-3d; }
.v3d .pc { height: 18.75%; background-size: contain; background-repeat: no-repeat; background-position: 50% 100%; transform-origin: 50% 100%; }
.v3d .pc.anim { transition: transform .22s ease-out; }
.v3d .sq .cf, .v3d .sq .cr { font-size: clamp(8px, 2.2vw, 12px); }
#s-game.table3d { background: radial-gradient(ellipse at 50% 35%, #f3e9d8 0%, #d9c6a6 55%, #a88d67 100%); }
[data-theme="dark"] #s-game.table3d { background: radial-gradient(ellipse at 50% 35%, #4a3d30 0%, #2c241c 60%, #17120d 100%); }
.table3d .topbar { background: linear-gradient(#e7d8bd, #cdb690); color: #3b2a17; box-shadow: 0 2px 8px rgba(60, 40, 20, .35); }
[data-theme="dark"] .table3d .topbar { background: linear-gradient(#4b3b2c, #33281e); color: #f0e2c8; }
.table3d .player-bar { background: linear-gradient(#e6d5b6, #c9b089); border-radius: 10px; box-shadow: 0 3px 8px rgba(60, 40, 20, .35), inset 0 1px 0 rgba(255, 255, 255, .5); margin: 6px auto; width: calc(100% - 20px); color: #33230f; font-family: Georgia, serif; }
.table3d .player-bar .nm small { color: #6b5236; }
.table3d .caps { background: #3b2f25; border-radius: 6px; padding: 2px 8px 2px 4px; height: 24px; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .6); width: fit-content; min-width: 60px; }
.table3d .caps img { width: 20px; height: 20px; object-fit: contain; }
.table3d .caps small { color: #f3dfb5; }
.table3d .clock { background: linear-gradient(#4a3a2c, #2c2219); color: #f6e7c8; font-family: Georgia, serif; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15); }
.table3d .clock.run { background: linear-gradient(#e9c46a, #c58f22); color: #2b1d08; }
.table3d .act { background: linear-gradient(#ead9ba, #c4aa80); border: 1px solid #8d7451; color: #3b2a17; box-shadow: 0 3px 6px rgba(60, 40, 20, .35); margin: 0 3px; border-radius: 10px; font-weight: 700; }
.table3d .act .icon { color: #4a3218; }
.table3d .opening, .table3d .moves .no { color: #5a4329; }
[data-theme="dark"] .table3d .opening, [data-theme="dark"] .table3d .moves .no { color: #d8c3a0; }
.table3d .moves button { color: #33230f; } [data-theme="dark"] .table3d .moves button { color: #f0e2c8; }
.table3d .moves button.cur { background: #6b4a2b; color: #fff; }
.table3d .banner-msg { background: rgba(255, 248, 232, .85); color: #33230f; }

/* v1.0.1 — stronger selection, legal moves and check warning (visible on light AND dark squares) */
:root { --sel-glow: #2df07a; --dot: rgba(40, 210, 110, .9); }
.sq.sel::before { background: rgba(45, 240, 122, .35); box-shadow: inset 0 0 0 4px var(--sel-glow), inset 0 0 18px rgba(45, 240, 122, .9); }
.sq .dot { width: 32%; height: 32%; background: var(--dot); box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 0 10px rgba(45, 240, 122, .9); }
.sq .ring { border: 5px solid var(--dot); box-shadow: 0 0 10px rgba(45, 240, 122, .9), inset 0 0 0 2px rgba(255, 255, 255, .8); }
.sq.last::before { background: rgba(255, 214, 64, .6); box-shadow: inset 0 0 0 3px rgba(255, 196, 0, .9); }
.sq.check { background-image: radial-gradient(circle, #ff2b2b 0%, rgba(255, 43, 43, .75) 45%, rgba(255, 43, 43, .25) 75%); box-shadow: inset 0 0 0 4px #ff2b2b; animation: checkPulse 0.8s ease-in-out 3; }
@keyframes checkPulse { 50% { box-shadow: inset 0 0 0 8px #ffdd00; } }
.pc.in-check { filter: drop-shadow(0 0 6px #ff1f1f) drop-shadow(0 0 12px #ff1f1f); animation: kingShake .45s ease-in-out 2; }
@keyframes kingShake { 25% { margin-left: -2px; } 75% { margin-left: 2px; } }
.pc.lifted { filter: drop-shadow(0 0 6px var(--sel-glow)) drop-shadow(0 0 14px var(--sel-glow)) brightness(1.08); }
.check-flash { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.6); z-index: 20; pointer-events: none; font: 900 clamp(34px, 11vw, 64px)/1 Georgia, serif; color: #fff; letter-spacing: 3px;
  padding: 8px 26px; border-radius: 14px; background: rgba(214, 30, 30, .9); box-shadow: 0 8px 30px rgba(214, 30, 30, .6); opacity: 0; }
.check-flash.show { animation: checkFlash 1.3s ease-out; }
@keyframes checkFlash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 30% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }

/* v1.1 — lobby, arena, daily games */
.arena-banner { display: flex; align-items: center; gap: var(--sp-3); width: calc(100% - 2 * var(--sp-4)); max-width: 560px; margin: 0 auto var(--sp-2); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-l);
  background: linear-gradient(135deg, #f6d36b, #e8a21f); color: #3b2500; box-shadow: 0 4px 12px var(--c-shadow); text-align: left; }
.arena-banner .grow { flex: 1; } .arena-banner b { display: block; font-size: var(--fs-l); } .arena-banner small { font-weight: 600; }
.arena-banner.live { background: linear-gradient(135deg, #ff6b4a, #d62d2d); color: #fff; animation: livePulse 1.6s ease-in-out infinite; }
@keyframes livePulse { 50% { box-shadow: 0 0 0 6px rgba(214, 45, 45, .25), 0 4px 12px var(--c-shadow); } }
.arena-icon { font-size: 30px; }
.arena-hero { display: flex; gap: var(--sp-3); align-items: center; background: linear-gradient(135deg, #f6d36b, #e8a21f); color: #3b2500; border-radius: var(--r-m); padding: var(--sp-4); margin: var(--sp-4) 0 var(--sp-3); }
.arena-hero.live { background: linear-gradient(135deg, #ff6b4a, #d62d2d); color: #fff; }
.arena-hero b { display: block; font-size: var(--fs-xl); } .arena-hero span { font-weight: 600; }
.lobby-line { text-align: center; color: var(--c-text-2); font-size: var(--fs-s); margin: var(--sp-2) 0; }
.seek-n { display: block; font-size: 10px; color: var(--c-success); font-weight: 700; }
.turn-badge { position: absolute; top: 8px; right: 12px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--c-danger); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; padding: 0 6px; }
.turn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-success); }
.modal .li { background: none; }
