:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #0e1621);
  --card: var(--tg-theme-section-bg-color, #1f2b38);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #7d8b99);
  --accent: var(--tg-theme-button-color, #5288c1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #ec3942);
  --gold: #f2b84b;
  --radius: 14px;
  --board: min(calc(100vw - 20px), 440px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.hint { color: var(--hint); margin: 0; font-size: 13px; }

#app { max-width: 480px; margin: 0 auto; padding: 12px 10px 24px; }
.screen { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- home ---------- */
.home-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; }
.logo { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; background: linear-gradient(135deg, #f2b84b, #c46d2a); box-shadow: 0 6px 18px rgba(242, 184, 75, .25); }
h1 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }

.game-tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.game-tab { grid-column: span 2; }
.game-tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; font-size: 14px; border-radius: var(--radius); border: 2px solid transparent; background: var(--card); font-weight: 600; transition: border-color .15s, transform .1s; }
.game-tab:active { transform: scale(.98); }
.game-tab.active { border-color: var(--gold); background: linear-gradient(180deg, rgba(242, 184, 75, .14), var(--card)); }
.tab-icon { font-size: 28px; line-height: 1; height: 30px; display: grid; place-items: center; }
.rules-line { text-align: center; padding: 8px 6px 4px; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.row2, .row3 { display: grid; gap: 8px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }

.btn { border: 0; border-radius: 11px; padding: 12px 10px; background: var(--accent); color: var(--accent-text); font-weight: 600; transition: transform .1s, opacity .15s; width: 100%; }
.btn:active { transform: scale(.97); }
.btn.secondary { background: rgba(127, 140, 153, .16); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--danger); }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-size: 13px; }

.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }
.join-row input { border: 0; border-radius: 11px; padding: 12px; background: rgba(127, 140, 153, .12); color: var(--text); font: 600 16px/1 ui-monospace, Menlo, monospace; letter-spacing: 3px; text-transform: uppercase; outline: none; min-width: 0; }
.join-row input::placeholder { letter-spacing: 0; font-family: inherit; font-weight: 400; color: var(--hint); text-transform: none; }
.join-row .btn { width: auto; padding: 12px 18px; }

.lobby-list { display: flex; flex-direction: column; gap: 6px; }
.lobby { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; background: rgba(127, 140, 153, .08); }
.lobby-icon { font-size: 22px; }
.lobby-info { flex: 1; min-width: 0; }
.lobby-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby .btn { width: auto; padding: 8px 14px; }
.empty { text-align: center; color: var(--hint); padding: 12px 0 4px; font-size: 13px; }

/* ---------- waiting ---------- */
.wait-box { background: var(--card); border-radius: var(--radius); padding: 24px 16px; margin-top: 30px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.wait-game { font-size: 20px; font-weight: 700; }
.badge { align-self: center; padding: 4px 10px; border-radius: 99px; background: rgba(242, 184, 75, .15); color: var(--gold); font-size: 12px; font-weight: 600; }
.code { font: 700 40px/1.1 ui-monospace, Menlo, monospace; letter-spacing: 8px; color: var(--gold); }
.spinner { width: 34px; height: 34px; margin: 10px auto 0; border-radius: 50%; border: 3px solid rgba(127, 140, 153, .25); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- game ---------- */
.player-bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--card); border-radius: 12px; margin: 6px 0; border: 2px solid transparent; transition: border-color .2s; }
.player-bar.turn { border-color: var(--gold); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.avatar.w { background: radial-gradient(circle at 35% 30%, #fff, #e3d8c3 60%, #b7a988); color: #3b2a12; }
.avatar.b { background: radial-gradient(circle at 35% 30%, #6a6a6a, #262626 60%, #0d0d0d); color: #eee; }
.pl-info { flex: 1; min-width: 0; }
.pl-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { font-size: 12px; color: var(--hint); }
.pl-right { font-size: 12px; color: var(--hint); text-align: right; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4fbf67; margin-right: 4px; }
.dot.off { background: var(--danger); }

.status { text-align: center; min-height: 22px; margin: 8px 0 4px; font-weight: 600; }
.status.yours { color: var(--gold); }
.game-actions { display: flex; justify-content: center; margin-top: 4px; }
.game-actions .btn { width: auto; padding: 10px 18px; }

#board-wrap { display: flex; justify-content: center; }

/* checkers */
.ck-board { width: var(--board); height: var(--board); display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); border-radius: 8px; overflow: hidden; border: 6px solid #5b3a1f; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.sq { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.sq.l { background: #ecd7ad; }
.sq.d { background: #9a6638; }
.sq.last { background: #b98a3e; }
.sq.dest::after { content: ""; width: 30%; height: 30%; border-radius: 50%; background: rgba(120, 255, 140, .75); box-shadow: 0 0 10px rgba(120, 255, 140, .8); }
.sq.capt { box-shadow: inset 0 0 0 3px rgba(255, 90, 90, .7); }
.pc { width: 80%; aspect-ratio: 1; height: auto; border-radius: 50%; position: relative; display: grid; place-items: center; font-size: calc(var(--board) / 8 * .38); transition: transform .12s; }
.pc.w { background: radial-gradient(circle at 35% 30%, #fff, #efe4cf 55%, #c9b78f); box-shadow: 0 3px 0 #a8956b, 0 5px 8px rgba(0, 0, 0, .35); color: #9a6a10; }
.pc.b { background: radial-gradient(circle at 35% 30%, #5d5d5d, #262626 55%, #0f0f0f); box-shadow: 0 3px 0 #000, 0 5px 8px rgba(0, 0, 0, .45); color: #f2b84b; }
.pc::before { content: ""; position: absolute; inset: 18%; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .12); }
.pc.b::before { border-color: rgba(255, 255, 255, .1); }
.pc.can { cursor: pointer; }
.pc.sel { transform: translateY(-3px) scale(1.06); outline: 3px solid var(--gold); outline-offset: 1px; }
.pc.movable { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 3px 0 #a8956b, 0 0 0 4px rgba(242, 184, 75, .55); } }

/* nardy */
.nd { width: var(--board); padding: 6px; border-radius: 10px; background: #5b3a1f; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); display: grid; grid-template-columns: 1fr 26px; gap: 5px; }
.nd-field { display: grid; grid-template-rows: 1fr 46px 1fr; background: #e8cf9f; border-radius: 6px; overflow: hidden; aspect-ratio: 1 / 1.08; }
.nd-row { display: grid; grid-template-columns: repeat(6, 1fr) 6px repeat(6, 1fr); }
.nd-bar { background: #5b3a1f; }
.pt { position: relative; display: flex; flex-direction: column; align-items: center; cursor: default; }
.nd-row.bottom .pt { flex-direction: column-reverse; }
.pt::before { content: ""; position: absolute; inset: 0 6%; clip-path: polygon(0 0, 100% 0, 50% 100%); background: var(--tri); opacity: .95; }
.nd-row.bottom .pt::before { clip-path: polygon(50% 0, 0 100%, 100% 100%); }
.pt.a { --tri: #9b4b25; }
.pt.b { --tri: #3f5b45; }
.pt.from::before { background: #f2b84b; }
.pt.dest::before { background: #5ccf73; }
.pt.can { cursor: pointer; }
.pt.lastfrom::after, .pt.lastto::after { content: ""; position: absolute; left: 50%; width: 6px; height: 6px; border-radius: 50%; transform: translateX(-50%); }
.nd-row.top .pt.lastto::after { bottom: 2px; background: #c0392b; }
.nd-row.bottom .pt.lastto::after { top: 2px; background: #c0392b; }
.ch { position: relative; width: 88%; aspect-ratio: 1; border-radius: 50%; margin-top: -10%; z-index: 1; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.nd-row.bottom .ch { margin-top: 0; margin-bottom: -10%; }
.ch:first-child { margin: 0 !important; }
.ch.w { background: radial-gradient(circle at 35% 30%, #fff, #efe4cf 55%, #c9b78f); box-shadow: 0 1px 2px rgba(0, 0, 0, .5); color: #6b4a12; }
.ch.b { background: radial-gradient(circle at 35% 30%, #5d5d5d, #262626 55%, #0f0f0f); box-shadow: 0 1px 2px rgba(0, 0, 0, .6); color: #f2b84b; }
.nd-mid { display: flex; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(#e8cf9f, #dfc28d); }
.die { width: 34px; height: 34px; border-radius: 8px; background: #fffaf0; box-shadow: 0 2px 0 #b9a77e, 0 3px 6px rgba(0, 0, 0, .3); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 4px; transition: opacity .2s; }
.die.used { opacity: .35; }
.die.opp { background: #2b2b2b; box-shadow: 0 2px 0 #000, 0 3px 6px rgba(0, 0, 0, .3); }
.die.opp i { background: #f2b84b; }
.die i { width: 6px; height: 6px; border-radius: 50%; background: #222; place-self: center; }
.nd-mid .x { font-size: 12px; color: #6b4a1f; font-weight: 700; }
.nd-off { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.off-box { flex: 1; border-radius: 6px; background: rgba(0, 0, 0, .28); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 3px 0; gap: 1px; color: #f2d9a8; font-size: 10px; font-weight: 700; }
.off-box.top { justify-content: flex-start; }
.off-box .bar { width: 18px; height: 4px; border-radius: 2px; }
.off-box .bar.w { background: #efe4cf; }
.off-box .bar.b { background: #222; }
.off-box.dest { background: rgba(92, 207, 115, .55); cursor: pointer; animation: glow 1.2s ease-in-out infinite; }
@keyframes glow { 50% { background: rgba(92, 207, 115, .85); } }
.notice { text-align: center; font-size: 12px; color: var(--hint); min-height: 16px; margin-top: 4px; }

/* result */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 10; padding: 20px; animation: fade .2s; }
.result-box { width: 100%; max-width: 340px; background: var(--card); border-radius: 18px; padding: 22px 18px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.result-emoji { font-size: 54px; }
.result-box h2 { font-size: 22px; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(20, 20, 20, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw; text-align: center; }

.ck-ico { position: relative; display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; }
.ck-ico i { position: absolute; width: 70%; height: 70%; border-radius: 50%; }
.ck-ico i:first-child { left: 0; top: 0; background: radial-gradient(circle at 35% 30%, #5d5d5d, #1a1a1a); }
.ck-ico i:last-child { right: 0; bottom: 0; background: radial-gradient(circle at 35% 30%, #fff, #d9cbb0); box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* game icons */
.chess-ico { font-family: "DejaVu Sans", "Segoe UI Symbol", "Apple Symbols", serif; color: var(--text); }
.ochko-ico { display: inline-grid; place-items: center; width: 1.05em; height: 1.4em; border-radius: 4px; background: #fff; color: #c0392b; font-size: .62em; font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.lobby-icon .ochko-ico, .wait-game .ochko-ico { font-size: 22px; }

.segmented { display: grid; grid-template-columns: 1fr 1.6fr; gap: 4px; margin-top: 8px; background: var(--card); padding: 4px; border-radius: 12px; }
.segmented.even { grid-template-columns: 1fr 1fr; }
.segmented button { border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--hint); }
.segmented button.active { background: rgba(242, 184, 75, .18); color: var(--gold); }

/* chess */
.chess-holder { position: relative; }
.ck-board.chess { border-color: #4a3423; }
.sq.cl { background: #f0d9b5; }
.sq.cd { background: #b58863; }
.sq.cl.last { background: #cdd26a; }
.sq.cd.last { background: #aaa23a; }
.sq.selsq { box-shadow: inset 0 0 0 3px rgba(242, 184, 75, .95); }
.sq.incheck { background: radial-gradient(circle, #ff3b3b 0%, rgba(255, 59, 59, .55) 45%, transparent 75%), #b58863; }
.sq.capdest { box-shadow: inset 0 0 0 4px rgba(46, 160, 67, .75); cursor: pointer; }
.chess .sq.dest::after { width: 28%; height: 28%; background: rgba(46, 160, 67, .7); box-shadow: none; }
.cp { font-family: "DejaVu Sans", "Segoe UI Symbol", "Apple Symbols", serif; font-size: calc(var(--board) / 8 * .78); line-height: 1; position: relative; z-index: 1; user-select: none; }
.cp.w { color: #fff; text-shadow: 0 0 1px #000, 0 0 1px #000, 1px 1px 0 #222, -1px -1px 0 #222, 1px -1px 0 #222, -1px 1px 0 #222, 0 3px 4px rgba(0,0,0,.35); }
.cp.b { color: #1d1d1d; text-shadow: 0 0 1px #000, 0 2px 3px rgba(0,0,0,.35), 0 0 1px rgba(255,255,255,.5); }
.coord { position: absolute; font-size: 9px; font-weight: 700; opacity: .7; z-index: 2; }
.coord.rank { left: 2px; top: 1px; }
.coord.file { right: 3px; bottom: 1px; }
.sq.cl .coord { color: #b58863; }
.sq.cd .coord { color: #f0d9b5; }
.promo { position: absolute; inset: 0; background: rgba(0,0,0,.6); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 5; }
.promo-title { font-weight: 700; }
.promo-row { display: flex; gap: 8px; }
.promo-row button { width: 64px; height: 64px; border-radius: 12px; border: 0; background: #f0d9b5; font-size: 46px; }

/* cards */
.pcard { --w: 58px; width: var(--w); height: calc(var(--w) * 1.42); flex: none; position: relative; border-radius: 7px; background: linear-gradient(160deg, #ffffff, #f1ece2); color: #1d1d1d; box-shadow: 0 2px 6px rgba(0,0,0,.35); border: 0; padding: 0; font-family: Georgia, "Times New Roman", serif; transition: transform .12s, opacity .15s; }
.pcard.sm { --w: 46px; }
.pcard.red { color: #c62828; }
.pcard .corner { position: absolute; left: 4px; top: 3px; font-size: calc(var(--w) * .24); line-height: .95; font-weight: 700; text-align: center; }
.pcard .corner.br { left: auto; top: auto; right: 4px; bottom: 3px; transform: rotate(180deg); }
.pcard .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .5); }
.pcard.joker .pip { font-size: calc(var(--w) * .55); }
.pcard.joker .jl { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font: 700 calc(var(--w) * .15) -apple-system, sans-serif; text-transform: uppercase; letter-spacing: .5px; }
.pcard.back { background: repeating-linear-gradient(45deg, #2f5d8a 0 5px, #3a6fa3 5px 10px); border: 3px solid #fff; }
.pcard.can { cursor: pointer; transform: translateY(-10px); box-shadow: 0 0 0 2px var(--gold), 0 6px 12px rgba(0,0,0,.4); }
.pcard.xfer { box-shadow: 0 0 0 2px #5aa9ff, 0 6px 12px rgba(0,0,0,.4); }
.pcard.chosen { transform: translateY(-16px); box-shadow: 0 0 0 3px #5ccf73, 0 6px 12px rgba(0,0,0,.4); }
.pcard.dim { filter: brightness(.55) saturate(.6); }
.pcard.is-trump::after { content: ""; position: absolute; right: 4px; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

.durak, .ochko { width: var(--board); display: flex; flex-direction: column; gap: 8px; }
.opp-hand { display: flex; justify-content: center; min-height: 66px; }
.opp-hand .pcard + .pcard { margin-left: -30px; }
.table-area { display: grid; grid-template-columns: 70px 1fr; gap: 8px; background: radial-gradient(ellipse at center, #2e6b46, #1f4d33); border-radius: 14px; padding: 10px; min-height: 190px; box-shadow: inset 0 2px 10px rgba(0,0,0,.4); }
.deck-zone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.deck-zone .trump { transform: rotate(90deg) translateY(-14px); }
.deck-zone .deck-back { position: absolute; top: 50%; left: 50%; transform: translate(-60%, -62%); }
.deck-count { margin-top: 10px; font-size: 12px; font-weight: 700; color: #d6f5df; position: relative; z-index: 2; text-align: center; line-height: 1.3; }
.deck-count .red { color: #ff8a80; }
.trump-suit { font-size: 40px; color: #fff; }
.trump-suit.red { color: #ff8a80; }
.table { display: flex; flex-wrap: wrap; gap: 10px 14px; align-content: center; justify-content: center; }
.table-empty { color: rgba(255,255,255,.55); font-size: 13px; align-self: center; }
.pair { position: relative; width: 62px; height: 80px; }
.pair .pcard { position: absolute; left: 0; top: 0; }
.pair .pcard.def { left: 14px; top: 14px; transform: rotate(12deg); }
.card-actions { display: flex; gap: 8px; justify-content: center; min-height: 0; }
.card-actions .btn { width: auto; min-width: 130px; padding: 11px 18px; }
.my-hand { display: flex; justify-content: center; padding-top: 12px; min-height: 100px; }
.my-hand .pcard + .pcard { margin-left: clamp(-42px, calc((var(--board) - var(--n) * 58px) / (var(--n) - 1)), 4px); }

.score-line { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.score { font: 800 26px/1 -apple-system, sans-serif; color: var(--gold); }
.o-hand { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 85px; padding: 12px; border-radius: 14px; background: radial-gradient(ellipse at center, #2e6b46, #1f4d33); }
.o-total { text-align: center; color: var(--hint); font-weight: 600; min-height: 18px; }
.o-total.big { font-size: 22px; color: var(--text); }
.o-total.bust { color: var(--danger); }
.o-total.bj { color: var(--gold); }
.round-banner { min-height: 0; text-align: center; display: flex; flex-direction: column; gap: 2px; border-radius: 12px; }
.round-banner.win, .round-banner.lose, .round-banner.draw { padding: 10px; }
.round-banner.win { background: rgba(79, 191, 103, .18); color: #7ee29a; }
.round-banner.lose { background: rgba(236, 57, 66, .16); color: #ff8b8b; }
.round-banner.draw { background: rgba(127, 140, 153, .18); }
.round-banner span { font-size: 13px; opacity: .85; }

/* domino */
.domino-ico { display: inline-flex; flex-direction: column; width: .62em; height: 1.2em; background: #fffaf0; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.4); padding: 2px 0; justify-content: space-around; align-items: center; border-bottom: 0; }
.domino-ico i { width: .16em; height: .16em; border-radius: 50%; background: #222; }
.lobby-icon .domino-ico, .wait-game .domino-ico { font-size: 22px; }
.domino { width: var(--board); display: flex; flex-direction: column; gap: 8px; }
.tile { --u: 22px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #fffdf7, #efe7d6); border-radius: 5px; border: 0; padding: 0; box-shadow: 0 2px 4px rgba(0,0,0,.35); flex: none; transition: transform .12s; }
.tile.h { width: calc(var(--u) * 2); height: var(--u); flex-direction: row; }
.tile.v { width: var(--u); height: calc(var(--u) * 2); flex-direction: column; }
.tile > b { flex: none; background: #b9ad94; }
.tile.h > b { width: 1px; height: 75%; }
.tile.v > b { height: 1px; width: 75%; }
.tile .half { width: var(--u); height: var(--u); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 3px; }
.tile .half i { width: calc(var(--u) * .17); height: calc(var(--u) * .17); border-radius: 50%; background: #1d1d1d; place-self: center; }
.tile.sm { --u: 16px; }
.tile.back { background: repeating-linear-gradient(45deg, #2f5d8a 0 4px, #3a6fa3 4px 8px); border: 2px solid #fff; }
.tile.last { box-shadow: 0 0 0 2px var(--gold), 0 2px 4px rgba(0,0,0,.35); }
.d-opp { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; min-height: 34px; }
.d-table { background: radial-gradient(ellipse at center, #2e6b46, #1f4d33); border-radius: 14px; padding: 12px 8px 8px; min-height: 170px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: inset 0 2px 10px rgba(0,0,0,.4); }
.d-chain { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; justify-content: center; align-content: center; flex: 1; }
.d-chain .tile { --u: 20px; }
.d-info { display: flex; justify-content: space-between; color: #d6f5df; font-size: 12px; margin-top: 8px; padding: 0 4px; }
.d-hand { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; padding-top: 10px; }
.d-hand .tile { --u: 26px; }
.d-hand .tile.can { cursor: pointer; transform: translateY(-8px); box-shadow: 0 0 0 2px var(--gold), 0 6px 12px rgba(0,0,0,.4); }
.d-hand .tile.sel { box-shadow: 0 0 0 3px #5ccf73, 0 6px 12px rgba(0,0,0,.4); transform: translateY(-12px); }
.d-hand .tile.dim { filter: brightness(.55); }
.card-actions { flex-wrap: wrap; }

/* board frame with coordinates */
.board-frame { --frame: 16px; --board: calc(min(calc(100vw - 20px), 440px) - var(--frame) - 4px); display: grid; grid-template-columns: var(--frame) auto; grid-template-rows: auto var(--frame); gap: 2px; justify-content: center; }
.frame-ranks { display: grid; grid-template-rows: repeat(8, 1fr); padding: 6px 0; }
.frame-files { display: grid; grid-template-columns: repeat(8, 1fr); padding: 0 6px; }
.frame-ranks span, .frame-files span { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--hint); }
.fx-ghost { position: absolute; pointer-events: none; z-index: 4; }
.sq { overflow: visible; }

/* captured pieces in player bars */
.captures { display: flex; align-items: center; gap: 4px; justify-content: flex-end; max-width: 160px; }
.cap-items { display: flex; flex-wrap: wrap; justify-content: flex-end; max-width: 130px; }
.captures b { color: var(--gold); font-size: 13px; }
.mini-pc { width: 12px; height: 12px; border-radius: 50%; margin-left: -4px; box-shadow: 0 1px 2px rgba(0,0,0,.5); display: inline-block; }
.mini-pc.w { background: radial-gradient(circle at 35% 30%, #fff, #d9cbb0); }
.mini-pc.b { background: radial-gradient(circle at 35% 30%, #666, #111); border: 1px solid #555; }
.mini-cp { font-style: normal; font-family: "DejaVu Sans", "Segoe UI Symbol", "Apple Symbols", serif; font-size: 17px; line-height: 1; margin-left: -2px; }
.mini-cp.w { color: #fff; text-shadow: 0 0 1px #000, 0 0 1px #000; }
.mini-cp.b { color: #111; text-shadow: 0 0 1px rgba(255,255,255,.7), 0 0 1px rgba(255,255,255,.7); }
.pl-sub .check { color: var(--danger); }

/* draw offer */
.game-actions { gap: 8px; }
.game-actions .btn:disabled { opacity: .45; }
.draw-panel { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(420px, calc(100vw - 24px)); background: var(--card); border: 2px solid var(--gold); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; text-align: center; font-weight: 600; z-index: 9; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: fade .2s; }

/* court card art */
.pcard .face { position: absolute; left: 16%; right: 16%; top: 12%; bottom: 12%; display: grid; place-items: center; }
.face-art { width: 100%; height: 100%; }

/* tic-tac-toe */
.ttt-ico { font-weight: 800; color: var(--gold); }
.ttt { width: min(var(--board), 360px); aspect-ratio: 1; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); gap: 8px; background: rgba(127,140,153,.25); padding: 8px; border-radius: 18px; }
.ttt-cell { border: 0; border-radius: 12px; background: var(--card); display: grid; place-items: center; padding: 14%; }
.ttt-cell.can:active { background: rgba(242,184,75,.15); }
.ttt-cell.win { background: rgba(242,184,75,.22); }
.mark { width: 100%; height: 100%; fill: none; stroke-width: 12; stroke-linecap: round; }
.mark.x { stroke: #ff7a7a; }
.mark.o { stroke: #6fb7ff; }
.mark.draw-in path, .mark.draw-in circle { stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw .35s ease-out forwards; }
.mark.draw-in path:nth-child(2) { animation-delay: .15s; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* rock-paper-scissors */
.rps { width: var(--board); display: flex; flex-direction: column; gap: 10px; }
.rps-arena { min-height: 230px; border-radius: 16px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 14px; text-align: center; }
.rps-hand { display: flex; flex-direction: column; align-items: center; }
.rps-hand span { font-size: 56px; line-height: 1.1; display: inline-block; }

.rps-hand small { color: var(--hint); }
.rps-vs { font-weight: 700; padding: 6px 12px; border-radius: 10px; }
.rps-vs.win { color: #7ee29a; background: rgba(79,191,103,.15); }
.rps-vs.lose { color: #ff8b8b; background: rgba(236,57,66,.14); }
.rps-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rps-btn { border: 2px solid transparent; border-radius: 14px; background: var(--card); padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .1s; }
.rps-btn span { font-size: 40px; }
.rps-btn small { font-size: 12px; color: var(--hint); }
.rps-btn:active { transform: scale(.95); }
.rps-btn.chosen { border-color: var(--gold); background: rgba(242,184,75,.12); }
.rps-btn:disabled:not(.chosen) { opacity: .45; }

/* battleship */
.bs { width: var(--board); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.bs-title { align-self: flex-start; font-weight: 700; font-size: 13px; color: var(--hint); }
.bs-grid { display: grid; grid-template-columns: 16px repeat(10, 1fr); gap: 2px; width: 100%; }
.bs-grid.small { width: 70%; }
.bs-h { display: grid; place-items: center; font-size: 10px; color: var(--hint); font-weight: 700; }
.bs-cell { aspect-ratio: 1; border-radius: 3px; background: #1d3b55; border: 0; padding: 0; position: relative; }
.bs-cell.can { background: #23486a; cursor: pointer; }
.bs-cell.can:active { background: #2f6491; }
.bs-cell.ship { background: #8ea4b5; }
.bs-cell.miss::after, .bs-cell.auto::after { content: ""; position: absolute; inset: 38%; border-radius: 50%; background: #9fb6c9; }
.bs-cell.auto::after { opacity: .45; }
.bs-cell.hit { background: #e0663f; }
.bs-cell.hit::after, .bs-cell.sunk::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 11px; }
.bs-cell.sunk { background: #8c2f2f; }
.bs-cell.last { box-shadow: 0 0 0 2px var(--gold); z-index: 1; }
.bs-fleet { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bs-ship { height: 8px; width: calc(var(--n) * 10px); border-radius: 3px; background: #8ea4b5; }
.bs-ship.dead { background: #8c2f2f; opacity: .6; }
.game-tab span:last-child { text-align: center; line-height: 1.15; }
