/* g-board.css : tictactoe, connect4, gomoku, reversi, mancala, dots, chess.
   Boards are physical grids (direction:ltr). Only selectors prefixed with the game class. */

/* ---------- shared shell ---------- */
.g-bd { --x: #2f9de4; --o: #ef5670; --hl: #f59e0b; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 390px; margin: 0 auto; }
.g-bd .g-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.g-bd .g-stage > .btn { width: 100%; max-width: 358px; min-height: 48px; }
.g-bd .g-foot { text-align: center; font-size: 13px; color: var(--sub); min-height: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.g-bd .banner { transition: color .2s, box-shadow .2s; }
.g-bd .banner[data-s='me'] { color: var(--accent); box-shadow: var(--glow); }
.g-bd .banner[data-s='win'] { color: var(--good); border-color: var(--good); }
.g-bd .banner[data-s='lose'] { color: var(--bad); border-color: var(--bad); }
.g-bd button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.g-bd button:disabled { opacity: 1; cursor: default; }
.g-bd .g-bar { display: flex; gap: 8px; }
.g-bd .g-bar .pl { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); transition: box-shadow .2s, border-color .2s; }
.g-bd .g-bar .pl.on { border-color: var(--accent); box-shadow: var(--glow); }
.g-bd .g-bar .pl.me .nm { font-weight: 800; }
.g-bd .g-bar .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.g-bd .g-bar .sc { font-size: 18px; font-variant-numeric: tabular-nums; padding: 0 4px; }
.g-bd .mk { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 11px; font-size: 12px; font-weight: 800; padding: 0 6px; color: #fff; }
.g-bd .mk.m0 { background: var(--x); }
.g-bd .mk.m1 { background: var(--o); }
.g-bd .mk.disc, .g-bd .mk.stone { padding: 0; width: 22px; border-radius: 50%; }
@keyframes bdpop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes bdpulse { 50% { filter: brightness(1.35) drop-shadow(0 0 6px var(--hl)); } }

/* ---------- tictactoe ---------- */
.g-tictactoe .ttt { direction: ltr; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 358px; aspect-ratio: 1; }
.g-tictactoe .c { border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2); font: 800 clamp(44px, 18vw, 70px)/1 'Vazirmatn', system-ui, sans-serif; color: var(--ink); padding: 0; transition: background .15s, transform .08s, box-shadow .2s; }
.g-tictactoe .c:not(:disabled):active { transform: scale(.95); }
.g-tictactoe .c:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.g-tictactoe .c.p0 { color: var(--x); }
.g-tictactoe .c.p1 { color: var(--o); }
.g-tictactoe .c.p0, .g-tictactoe .c.p1 { animation: bdpop .2s ease-out; }
.g-tictactoe .c.last { border-color: var(--hl); }
.g-tictactoe .c.win { background: color-mix(in srgb, var(--hl) 28%, var(--panel-2)); border-color: var(--hl); box-shadow: 0 0 14px color-mix(in srgb, var(--hl) 55%, transparent); animation: bdpulse 1s ease-in-out infinite; }

/* ---------- connect4 ---------- */
.g-connect4 .c4 { direction: ltr; display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; width: 100%; max-width: 358px; padding: 8px; border-radius: 18px; background: #1d4ed8; box-shadow: inset 0 -4px 0 #1639a8; }
.g-connect4 .col { display: grid; grid-template-rows: repeat(6, auto); gap: 5px; padding: 0; border: 0; background: transparent; border-radius: 10px; min-width: 0; transition: background .15s; }
.g-connect4 .col:not(:disabled):hover, .g-connect4 .col:not(:disabled):active { background: rgba(255, 255, 255, .18); }
.g-connect4 .d { aspect-ratio: 1; border-radius: 50%; background: #0b1b4d; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5); }
.g-connect4 .d.p0 { background: radial-gradient(circle at 35% 30%, #ff8a8a, #ef4444 55%, #b91c1c); }
.g-connect4 .d.p1 { background: radial-gradient(circle at 35% 30%, #fff0a0, #facc15 55%, #ca9a04); }
.g-connect4 .d.last { animation: c4drop .35s cubic-bezier(.4, 0, .6, 1.2); box-shadow: 0 0 0 2px #fff; }
.g-connect4 .d.win { box-shadow: 0 0 0 3px #fff, 0 0 12px #fff; animation: bdpulse .9s ease-in-out infinite; }
@keyframes c4drop { from { transform: translateY(-260%); } to { transform: none; } }
.g-connect4 .mk.disc.d0 { background: #ef4444; }
.g-connect4 .mk.disc.d1 { background: #facc15; }

/* ---------- gomoku ---------- */
.g-gomoku .gm { direction: ltr; display: grid; grid-template-columns: repeat(15, 1fr); width: 100%; max-width: 358px; aspect-ratio: 1; background: #e2b765; border-radius: 10px; padding: 4px; box-shadow: inset 0 0 0 2px #b88a3a; }
.g-gomoku .gm > button { position: relative; padding: 0; border: 0; background: transparent; border-radius: 50%; min-width: 0; min-height: 0; }
.g-gomoku .gm > button::before, .g-gomoku .gm > button::after { content: ''; position: absolute; background: #5a3d12; }
.g-gomoku .gm > button::before { left: 0; right: 0; top: 50%; height: 1px; }
.g-gomoku .gm > button::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.g-gomoku .gm .el::before { left: 50%; } .g-gomoku .gm .er::before { right: 50%; }
.g-gomoku .gm .et::after { top: 50%; } .g-gomoku .gm .eb::after { bottom: 50%; }
.g-gomoku .gm .star { background: radial-gradient(circle, #5a3d12 0 14%, transparent 16%); }
.g-gomoku .gm .p0, .g-gomoku .gm .p1 { background-repeat: no-repeat; background-position: center; background-size: 88% 88%; animation: bdpop .18s ease-out; }
.g-gomoku .gm .p0 { background-image: radial-gradient(circle at 35% 30%, #666 0, #111 60%, #111 68%, transparent 70%); }
.g-gomoku .gm .p1 { background-image: radial-gradient(circle at 35% 30%, #fff 0, #f1f1f1 55%, #cfcfcf 68%, transparent 70%); }
.g-gomoku .gm .p0::before, .g-gomoku .gm .p0::after, .g-gomoku .gm .p1::before, .g-gomoku .gm .p1::after { display: none; }
.g-gomoku .gm .n.last::after { display: block; left: 50%; top: 50%; bottom: auto; width: 34%; height: 34%; transform: translate(-50%, -50%); border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 1px #fff8; }
.g-gomoku .gm .win { filter: drop-shadow(0 0 3px var(--hl)) drop-shadow(0 0 3px var(--hl)); animation: bdpulse .9s ease-in-out infinite; }
.g-gomoku .gm .sel { background-repeat: no-repeat; background-position: center; background-size: 88% 88%; }
.g-gomoku .gm .sel0 { background-image: radial-gradient(circle, rgba(17, 17, 17, .6) 0 66%, transparent 70%); }
.g-gomoku .gm .sel1 { background-image: radial-gradient(circle, rgba(255, 255, 255, .85) 0 66%, transparent 70%); }
.g-gomoku .gm .n.sel::before { display: none; }
.g-gomoku .gm .n.sel::after { display: block; left: 50%; top: 50%; bottom: auto; width: 110%; height: 110%; transform: translate(-50%, -50%); border-radius: 50%; background: transparent; border: 2px solid #2563eb; animation: bdpulse 1s infinite; }
.g-gomoku .mk.stone.s0 { background: #111; box-shadow: 0 0 0 1px var(--line); }
.g-gomoku .mk.stone.s1 { background: #f5f5f5; box-shadow: 0 0 0 1px var(--line); }

/* ---------- reversi ---------- */
.g-reversi .rv { direction: ltr; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; width: 100%; max-width: 358px; aspect-ratio: 1; padding: 4px; border-radius: 12px; background: #0f5132; }
.g-reversi .c { position: relative; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 4px; background: #198754; min-width: 0; min-height: 0; transition: background .15s; }
.g-reversi .c i { display: block; width: 82%; height: 82%; border-radius: 50%; background: transparent; transition: background .3s, transform .3s, box-shadow .3s; }
.g-reversi .c.p0 i { background: radial-gradient(circle at 35% 30%, #555, #0c0c0c 65%); box-shadow: 0 2px 3px rgba(0, 0, 0, .45); }
.g-reversi .c.p1 i { background: radial-gradient(circle at 35% 30%, #fff, #e8e8e8 60%, #bdbdbd); box-shadow: 0 2px 3px rgba(0, 0, 0, .45); }
.g-reversi .c.last { box-shadow: inset 0 0 0 2px #fde047; }
.g-reversi .c.hint { background: #22a06b; }
.g-reversi .c.hint i { width: 26%; height: 26%; background: rgba(255, 255, 255, .55); animation: bdpop .2s ease-out; }
.g-reversi .c.hint:active { background: #2fbf80; }
.g-reversi .mk.disc.d0 { background: #111; box-shadow: 0 0 0 1px var(--line); }
.g-reversi .mk.disc.d1 { background: #f5f5f5; box-shadow: 0 0 0 1px var(--line); }

/* ---------- mancala ---------- */
.g-mancala .mc { direction: ltr; display: grid; grid-template-columns: 1.15fr repeat(6, 1fr) 1.15fr; grid-template-rows: 1fr 1fr; gap: 6px; width: 100%; max-width: 358px; aspect-ratio: 358 / 160; padding: 8px; border-radius: 22px; background: #8b5a2b; box-shadow: inset 0 0 0 2px #5f3a16; }
.g-mancala .store, .g-mancala .pit { display: flex; align-items: center; justify-content: center; border: 0; padding: 0; min-width: 0; min-height: 0; background: #5f3a16; color: #fff3d6; font: 800 17px/1 'Vazirmatn', system-ui, sans-serif; box-shadow: inset 0 3px 6px rgba(0, 0, 0, .5); transition: background .2s, box-shadow .2s, transform .1s; }
.g-mancala .pit { border-radius: 50%; }
.g-mancala .store { border-radius: 40px; font-size: 22px; grid-row: 1 / 3; }
.g-mancala .mc > :nth-child(1) { grid-column: 1; }
.g-mancala .mc > :nth-child(8) { grid-column: 8; }
.g-mancala .mc > :nth-child(2), .g-mancala .mc > :nth-child(9) { grid-column: 2; }
.g-mancala .mc > :nth-child(3), .g-mancala .mc > :nth-child(10) { grid-column: 3; }
.g-mancala .mc > :nth-child(4), .g-mancala .mc > :nth-child(11) { grid-column: 4; }
.g-mancala .mc > :nth-child(5), .g-mancala .mc > :nth-child(12) { grid-column: 5; }
.g-mancala .mc > :nth-child(6), .g-mancala .mc > :nth-child(13) { grid-column: 6; }
.g-mancala .mc > :nth-child(7), .g-mancala .mc > :nth-child(14) { grid-column: 7; }
.g-mancala .pit:not(.mine) { grid-row: 1; }
.g-mancala .pit.mine { grid-row: 2; }
.g-mancala .pit.ok { background: #7a4a1c; box-shadow: inset 0 3px 6px rgba(0, 0, 0, .4), 0 0 0 2px #ffd479; }
.g-mancala .pit.ok:active { transform: scale(.92); }
.g-mancala .last { background: #a8741f; box-shadow: inset 0 3px 6px rgba(0, 0, 0, .35), 0 0 0 2px #fde047; }
.g-mancala .mk { color: #fff; }

/* ---------- dots and boxes ---------- */
.g-dots .db { direction: ltr; display: grid; grid-template-columns: repeat(5, 12px 1fr) 12px; grid-template-rows: repeat(5, 12px 1fr) 12px; width: 100%; max-width: 358px; aspect-ratio: 1; padding: 10px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); }
.g-dots .dt { align-self: center; justify-self: center; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); z-index: 2; pointer-events: none; }
.g-dots .ln { position: relative; padding: 0; border: 0; background: transparent; z-index: 1; min-width: 0; min-height: 0; }
.g-dots .ln::before { content: ''; position: absolute; border-radius: 4px; background: color-mix(in srgb, var(--sub) 28%, transparent); transition: background .2s; }
.g-dots .ln.h::before { left: 2px; right: 2px; top: 3px; bottom: 3px; }
.g-dots .ln.v::before { top: 2px; bottom: 2px; left: 3px; right: 3px; }
.g-dots .ln::after { content: ''; position: absolute; }
.g-dots .ln.h::after { left: 0; right: 0; top: -14px; bottom: -14px; }
.g-dots .ln.v::after { top: 0; bottom: 0; left: -14px; right: -14px; }
.g-dots .ln:not(:disabled):active::before { background: var(--accent); }
.g-dots .ln.p0::before { background: var(--x); }
.g-dots .ln.p1::before { background: var(--o); }
.g-dots .ln.last::before { box-shadow: 0 0 8px currentColor, 0 0 0 2px var(--hl); animation: bdpulse 1s ease-in-out 2; }
.g-dots .ln.p0 { color: var(--x); } .g-dots .ln.p1 { color: var(--o); }
.g-dots .bx { display: flex; align-items: center; justify-content: center; margin: 4px; border-radius: 8px; font-weight: 800; font-size: 20px; color: #fff; pointer-events: none; }
.g-dots .bx.p0 { background: color-mix(in srgb, var(--x) 80%, #000 0%); animation: bdpop .25s ease-out; }
.g-dots .bx.p1 { background: color-mix(in srgb, var(--o) 80%, #000 0%); animation: bdpop .25s ease-out; }
.g-dots .mk { width: 22px; padding: 0; }

/* ---------- chess ---------- */
.g-chess .pl { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 358px; padding: 6px 12px; min-height: 44px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); transition: box-shadow .2s, border-color .2s; }
.g-chess .pl.on { border-color: var(--accent); box-shadow: var(--glow); }
.g-chess .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; }
.g-chess .cap { display: inline-flex; align-items: center; flex: none; border-radius: 10px; padding: 0 6px; background: #7d6b55; min-height: 24px; letter-spacing: -5px; }
.g-chess .cap:empty { display: none; }
.g-chess .cap .pc { font-size: 18px; line-height: 1; }
.g-chess .ck { flex: none; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px; padding: 2px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); direction: ltr; }
.g-chess .ck.act { color: var(--accent); border-color: var(--accent); }
.g-chess .ck.low { color: var(--bad); border-color: var(--bad); }
.g-chess .bw { position: relative; width: 100%; max-width: 358px; }
.g-chess .bd { container-type: inline-size; direction: ltr; display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px var(--line); }
.g-chess .sq { position: relative; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 0; min-width: 0; min-height: 0; transition: background-color .15s; }
.g-chess .sq.lt { background-color: #ecd9b4; color: #9a7448; }
.g-chess .sq.dk { background-color: #a9794e; color: #f3e3c3; }
.g-chess .sq::before, .g-chess .sq::after { position: absolute; font-size: 9px; font-weight: 700; line-height: 1; pointer-events: none; }
.g-chess .sq::before { content: attr(data-r); top: 2px; left: 3px; }
.g-chess .sq::after { content: attr(data-f); bottom: 2px; right: 3px; }
.g-chess .sq.last.lt { background-color: #f4e585; }
.g-chess .sq.last.dk { background-color: #d2b43f; }
.g-chess .sq.sel { background-color: #7fc4f5; box-shadow: inset 0 0 0 3px #2563eb; }
.g-chess .sq.chk { background-image: radial-gradient(circle, #ef4444 0, rgba(239, 68, 68, .75) 35%, rgba(239, 68, 68, 0) 75%); }
.g-chess .sq.tgt { background-image: radial-gradient(circle, rgba(20, 20, 20, .38) 0 17%, transparent 19%); }
.g-chess .sq.tgt.cap { background-image: radial-gradient(circle, transparent 0 58%, rgba(220, 38, 38, .6) 60%); }
.g-chess .sq:not(:disabled):active { filter: brightness(1.12); }
.g-chess .sq .pc { font-size: 10cqw; line-height: 1; position: relative; z-index: 1; animation: bdpop .15s ease-out; }
.g-chess .pc { font-family: 'Noto Sans Symbols 2', 'Segoe UI Symbol', 'DejaVu Sans', system-ui, sans-serif; font-weight: 400; paint-order: stroke fill; }
.g-chess .pc.w { color: #fff; -webkit-text-stroke: 1px #2a1d10; text-shadow: 0 1px 1px rgba(0, 0, 0, .35); }
.g-chess .pc.b { color: #151515; -webkit-text-stroke: .6px rgba(255, 255, 255, .55); text-shadow: 0 1px 1px rgba(0, 0, 0, .3); }
.g-chess .promo { position: absolute; inset: 0; z-index: 3; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 10px; padding: 14px; border-radius: 8px; background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--accent); box-shadow: var(--glow); }
.g-chess .promo[hidden] { display: none; }
.g-chess .pr-t { flex: 0 0 100%; text-align: center; font-weight: 800; }
.g-chess .pr { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; padding: 0; border: 2px solid var(--line); border-radius: 14px; background: #ecd9b4; transition: transform .1s, border-color .15s; }
.g-chess .pr:active { transform: scale(.94); border-color: var(--accent); }
.g-chess .pr .pc { font-size: 40px; line-height: 1; }
.g-chess .promo > .btn { flex: 0 0 100%; max-width: 200px; }
