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

.cm-stage { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cm-stage canvas { display: block; width: 100%; height: 420px; cursor: text; }
.cm-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; overflow-y: auto; background: color-mix(in srgb, var(--bg) 55%, transparent); }
.cm-overlay-card { position: relative; width: min(480px, 100%); margin: auto; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; }
.typing-game .cm-overlay-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.cm-overlay-close:hover { background: var(--current); color: var(--text); }
.cm-overlay-card h2 { margin: 0 0 6px; font-size: var(--large); font-weight: 700; }
.cm-overlay-card p { margin: 0 0 12px; color: var(--muted); }
.cm-overlay-card p:empty { display: none; }
.cm-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 0 0 12px; }
.cm-stats div { padding: 6px 4px; border-radius: 8px; background: var(--bg); }
.cm-stats dt { color: var(--muted); font-size: var(--small); }
.cm-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.cm-save.is-saved { color: var(--ok) !important; font-weight: 600; }
.cm-save.is-failed { color: var(--bad) !important; }
.cm-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); color: #fff; font-size: 56px; font-weight: 700; text-shadow: 0 2px 12px #0008; pointer-events: none; }
.cm-banner.is-show { animation: cm-pop 1s ease-out; }
@keyframes cm-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.cm-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; margin-top: 10px; }
.typing-game .cm-input-row .tg-chip { height: 52px; }
.typing-game .cm-full { min-width: 52px; font-size: 22px; line-height: 1; }
.typing-game .cm-resign { padding: 0 14px; color: var(--bad); border-color: var(--bad); font-weight: 600; }
.typing-game .cm-resign.is-confirm { background: var(--bad); color: #fff; }
.cm-input-row .tg-input.is-miss { animation: cm-shake .25s; border-color: var(--bad); }
@keyframes cm-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.cm-target { display: grid; place-items: center; min-width: 150px; max-width: 260px; height: 52px; padding: 0 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.cm-target.is-locked { border-color: var(--accent); color: var(--accent); }

@media (max-width: 699px) {
    .cm-hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cm-input-row { grid-template-columns: minmax(0, 1fr) auto auto; }
    .cm-input-row .tg-input { grid-column: 1 / -1; }
    .cm-target { max-width: none; height: 40px; }
    .typing-game .cm-input-row .tg-chip { height: 40px; }
    .typing-game .cm-full { min-width: 40px; }
    .cm-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.typing-game .cm-select { height: 38px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.typing-game .cm-select:disabled { opacity: .6; }
.cm-overlay-card p { white-space: pre-line; }

.camap-ime { min-width: 34px; padding: 6px 0; font-weight: 800; font-size: 15px; line-height: 1; text-align: center; color: #fff; background: #2563eb; border-color: #2563eb; }
.camap-ime.is-vi { background: #dc2626; border-color: #dc2626; color: #fff; }
.camap-ime[aria-pressed="true"] { color: #fff; border-color: #dc2626; }

.cm-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); }
.cm-play.is-full .cm-stage { flex: 1 1 auto; min-height: 240px; }
.cm-play.is-full .cm-stage canvas { position: absolute; inset: 0; height: 100%; }
.cm-play.is-full .cm-full { color: var(--accent); border-color: var(--accent); }
body.cm-full-open { overflow: hidden; }

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