:root { --ba-board: #eef2f8; --ba-cell: #ffffff; --ba-cell-line: #cfd8e6; --ba-gold: #b7791f; --ba-gold-soft: #fff4d6; }
:root[data-theme="dark"] { --ba-board: #121a26; --ba-cell: #1d2635; --ba-cell-line: #33415a; --ba-gold: #fbbf24; --ba-gold-soft: #3a2f12; }

.tg-top:has(.ba-tagline) h1 { flex: 0 0 auto; }
.ba-tagline { flex: 1 1 240px; margin: 0; padding: 6px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.ba-hud { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin: 0 0 10px; }
.ba-hud div { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ba-hud dt { color: var(--muted); font-size: var(--small); }
.ba-hud dd { margin: 0; overflow: hidden; font-weight: 600; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.ba-hud .ba-lives { color: var(--bad); letter-spacing: 1px; }

.ba-stage { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--ba-board); }
.ba-stage.is-hurt { animation: ba-hurt .35s; }
@keyframes ba-hurt { 30% { box-shadow: inset 0 0 0 4px var(--bad); } }

.ba-banner { position: absolute; z-index: 3; left: 50%; top: 40%; transform: translate(-50%, -50%); color: var(--accent); font-size: 52px; font-weight: 800; text-shadow: 0 2px 12px color-mix(in srgb, var(--bg) 80%, transparent); pointer-events: none; white-space: nowrap; }
.ba-banner.is-show { animation: ba-pop 1s ease-out forwards; }
@keyframes ba-pop { from { opacity: 0; scale: .7; } 25% { opacity: 1; scale: 1.05; } 70% { opacity: 1; scale: 1; } to { opacity: 0; } }

.ba-overlay { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; padding: 12px; overflow-y: auto; background: color-mix(in srgb, var(--bg) 60%, transparent); cursor: default; }
.ba-overlay-card { width: min(500px, 100%); margin: auto; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; }
.ba-overlay-card h2 { margin: 0 0 6px; font-size: var(--large); font-weight: 700; }
.ba-overlay-card p { margin: 0 0 12px; color: var(--muted); }
.ba-overlay-card p:empty { display: none; }
.ba-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; margin: 0 0 12px; }
.ba-stats div { padding: 6px 4px; border-radius: 8px; background: var(--bg); }
.ba-stats dt { color: var(--muted); font-size: var(--small); }
.ba-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.ba-save.is-saved { color: var(--ok) !important; font-weight: 600; }
.ba-save.is-failed { color: var(--bad) !important; }

.ba-controls { display: flex; align-items: stretch; gap: 8px; margin-top: 10px; }
.ba-controls > .ba-grow { flex: 1 1 auto; min-width: 0; }
.typing-game .ba-controls .tg-chip { height: 52px; }
.typing-game .ba-full { min-width: 52px; font-size: 22px; line-height: 1; }
.typing-game .ba-resign { padding: 0 14px; color: var(--bad); border-color: var(--bad); font-weight: 600; white-space: nowrap; }
.typing-game .ba-resign.is-confirm { background: var(--bad); color: #fff; }
.ba-hint { display: flex; align-items: center; min-height: 52px; margin: 0; padding: 6px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: var(--small); }

@media (pointer: coarse) {
    .ba-keys { font-size: 0; }
    .ba-keys::after { content: attr(data-touch); font-size: var(--small); }
}

@media (max-width: 699px) {
    .ba-hud .ba-hud-extra { display: none; }
    .typing-game .ba-controls .tg-chip { height: 44px; }
    .typing-game .ba-full { min-width: 44px; }
    .ba-hint { min-height: 44px; }
}

.tg-main:has(.ba-play) { max-width: 1360px; }
@media (min-width: 1300px) {
    .tg-main:has(.ba-play) .arcade-game-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; }
}

.ba-play.is-full { position: fixed; inset: 0; z-index: 2147483000; display: flex; flex-direction: column; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); overflow: auto; background: var(--bg); }
.ba-play.is-full .ba-stage { flex: 1 1 auto; height: auto; min-height: 260px; }
.ba-play.is-full .ba-full { color: var(--accent); border-color: var(--accent); }
body.ba-full-open { overflow: hidden; }
