/* 2048: розкладка гри, поле завжди квадратне. */
html,body{height:100%;overflow:hidden;background:#fff}
.ba-g2048{height:100%;max-width:none;display:grid;grid-template-rows:auto minmax(0,1fr) auto;padding:14px;gap:12px}
.ba-g2048 [hidden]{display:none!important}
.ba-g2048>*{min-width:0}
.ba-g2048 a{color:inherit}

.ba-g2048 .ba-game-head{display:grid!important;grid-template-columns:minmax(0,1fr) auto;gap:18px!important;padding:0 0 12px!important;margin:0!important;border-bottom:1px solid #ccc;align-items:center!important}
.ba-g2048 .ba-game-head>div:first-child{display:flex!important;flex-direction:column;align-items:flex-start!important;gap:5px}
.ba-g2048 .ba-game-head h3{font-size:23px;line-height:1}
.ba-g2048 .ba-game-head .ba-kicker{font-size:10px;color:#666;letter-spacing:.06em;margin:0}
.ba-g2048 .ba-stats-top{margin:0;padding:0;gap:16px;font-size:11px;flex-wrap:nowrap;align-items:center}
.ba-g2048 .ba-stats-top span{display:flex;flex-direction:column;gap:5px}
.ba-g2048 .ba-stats-top b{font-size:21px;font-weight:800}
.ba-g2048 .ba-stat-stage b{font:900 18px/1.15 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:-.03em;overflow:visible}

.ba-g2048 .ba-game-layout{display:grid;grid-template-columns:minmax(0,1fr) 170px;align-items:stretch;gap:20px;border:0;min-height:0;min-width:0}
.ba-g2048 .ba-board-shell{border:0;padding:0;min-height:0;min-width:0;display:flex;justify-content:center;align-items:center}
.ba-g2048 .ba-board-wrap{width:var(--field-size,300px);height:var(--field-size,300px);margin:0;padding:calc(var(--field-size,300px) * .022);flex-shrink:0}
.ba-g2048 .ba-board{gap:calc(var(--field-size,300px) * .022);height:100%}
.ba-g2048 .ba-tile strong{padding:2px;white-space:nowrap;word-break:normal;letter-spacing:-.04em;font-size:max(14px,calc(var(--field-size,300px) * .075))}
.ba-g2048 .ba-tile small{display:none}
.ba-g2048 .ba-start-card{width:min(100%,300px);padding:20px}
.ba-g2048 .ba-start-kicker{font-size:11px}
.ba-g2048 .ba-start-card small{font-size:14px}
.ba-g2048 .ba-start-card button{font-size:14px!important}

.ba-g2048 .ba-side{padding:0;background:#fff;min-height:0;justify-content:center}
.ba-g2048 .ba-controls-zone{margin:0;padding:0}
.ba-g2048 .ba-dpad{width:100%;gap:6px}
.ba-g2048 .ba-dpad button{min-height:52px;font-size:22px!important}

.ba-g2048 .arcade-footer{border-top:1px solid #ccc;padding-top:10px}
.ba-g2048 .arcade-footer p{font:13px/1.5 system-ui,sans-serif;color:#555;margin:0 0 8px}
.ba-g2048 .arcade-footer>div{display:flex;justify-content:space-between;gap:10px}
.ba-g2048 .arcade-footer button{border:0;background:transparent;padding:5px 0;color:#111;text-decoration:underline;cursor:pointer;font-size:13px}


@media(max-width:520px){
.ba-g2048{padding:10px;gap:10px}
.ba-g2048 .ba-game-head{grid-template-columns:minmax(0,1fr) auto;gap:7px!important;padding-bottom:8px!important}
.ba-g2048 .ba-game-head h3{font-size:15px}
.ba-g2048 .ba-game-head .ba-kicker{font-size:8px}
.ba-g2048 .ba-stats-top{gap:9px;font-size:8px}
.ba-g2048 .ba-stats-top b{font-size:16px}
.ba-g2048 .ba-stat-stage b{font-size:13px}
.ba-g2048 .ba-game-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;gap:10px}
.ba-g2048 .ba-side{display:block}
/* One row of arrows on phones: ← ↑ ↓ → */
.ba-g2048 .ba-dpad{display:grid;grid-template-columns:repeat(4,minmax(0,1fr))}
.ba-g2048 .ba-dpad>span{display:none}
.ba-g2048 .ba-dpad [data-ba-dir="left"]{order:1}
.ba-g2048 .ba-dpad [data-ba-dir="up"]{order:2}
.ba-g2048 .ba-dpad [data-ba-dir="down"]{order:3}
.ba-g2048 .ba-dpad [data-ba-dir="right"]{order:4}
.ba-g2048 .ba-dpad button{min-height:48px}
.ba-g2048 .arcade-footer p{font-size:12px;margin-bottom:4px}
.ba-g2048 .arcade-footer button{font-size:12px}
}
@media(max-width:360px){.ba-g2048 .ba-stats-top span:nth-child(3){display:none}}
@media(max-height:500px){
.ba-g2048{padding:8px;gap:7px}
.ba-g2048 .ba-game-head{padding-bottom:6px!important}
.ba-g2048 .ba-game-head h3{font-size:16px}
.ba-g2048 .ba-game-head .ba-kicker{display:none}
.ba-g2048 .ba-stats-top b{font-size:16px}
.ba-g2048 .arcade-footer{padding-top:6px}
.ba-g2048 .arcade-footer p{font-size:11px;line-height:1.3;margin-bottom:3px}
.ba-g2048 .arcade-footer button{font-size:12px}
}

/* Arrow glyphs stay monochrome text (some systems otherwise pick a colour emoji font for ↑ ↓). */
.ba-g2048 .ba-dpad button{color:#111!important;font-family:Arial,"Segoe UI Symbol",ui-monospace,monospace!important;font-variant-emoji:text}
.ba-g2048 .ba-dpad button:active{color:#fff!important}

/* Підсумок гри всередині вікна гри */
.ba-g2048 .ba-over{padding:6px;align-items:center;justify-content:center}
.ba-g2048 .ba-over-card{box-sizing:border-box;width:min(100%,460px);max-height:100%;overflow:auto;padding:22px;box-shadow:5px 6px #111}
.ba-g2048 .ba-over-card h3{font-size:clamp(22px,5vw,30px);line-height:1.1}
.ba-g2048 .ba-over-card>p{margin:10px 0 14px;font-size:14px;line-height:1.4}
.ba-g2048 .ba-over-actions{display:flex;gap:8px}
.ba-g2048 .ba-over-actions button{flex:1 1 0;min-height:46px}
