.card { background: var(--clr-surface); border-radius: var(--radius); padding: 1.1rem; box-shadow: 0 1px 3px rgba(18, 48, 46, .08); display: grid; gap: 1rem; }
.card p, .card h2 { margin: 0; }
.card fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.card legend { padding: 0; margin-bottom: .6rem; font-weight: 700; }
.muted { color: var(--clr-muted); font-size: .9rem; }

.seg { display: flex; flex-wrap: wrap; gap: .5rem; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; min-width: 5.5rem; padding: .4rem .9rem;
  border: 1.5px solid var(--clr-border); border-radius: 12px; background: #fff;
}
.opt small { color: var(--clr-muted); font-size: .78rem; }
.opt input:checked + span { background: var(--clr-base-strong); border-color: var(--clr-base-strong); color: #fff; font-weight: 600; }
.opt input:checked + span small { color: rgba(255, 255, 255, .85); }
.opt:has(input:focus-visible) span { outline: 3px solid var(--clr-focus); outline-offset: 2px; }

.toggle { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .75rem; min-height: 44px; }
.toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--clr-base); }

.play { display: grid; gap: .75rem; justify-items: center; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.bar { margin: 0; display: flex; gap: 1rem; align-items: baseline; justify-content: center; font-size: 1.05rem; }

.stage { position: relative; --side: min(100vw - 2rem, 420px, 52vh); width: var(--side); height: var(--side); }
.stage canvas { display: block; width: 100%; height: 100%; border-radius: 14px; box-shadow: 0 1px 3px rgba(18, 48, 46, .18); touch-action: none; }
.overlay {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .8rem; padding: 1rem; text-align: center;
  border-radius: 14px; background: rgba(242, 245, 244, .82); pointer-events: none;
}
.overlay[hidden] { display: none; }
.overlay p { margin: 0; font-weight: 600; color: var(--clr-base-strong); font-size: 1.05rem; }
.overlay .btn { pointer-events: auto; }

.pad {
  touch-action: none; display: grid; grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(2, 72px); gap: .5rem;
  grid-template-areas: ". up ." "left down right";
}
.key {
  display: grid; place-items: center; width: 72px; height: 72px; padding: 0; border: 0; border-radius: 18px;
  background: var(--clr-base-strong); color: #fff; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.key svg { width: 34px; height: 34px; fill: currentColor; pointer-events: none; }
.key:active { background: var(--clr-base); }
.key:focus-visible { outline: 3px solid var(--clr-focus); outline-offset: 2px; }
.key--up { grid-area: up; } .key--left { grid-area: left; } .key--down { grid-area: down; } .key--right { grid-area: right; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.actions .btn { min-width: 8rem; }

.info summary, .data summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.data__actions { display: grid; gap: .6rem; }
.data__actions .btn { width: 100%; }
.status { color: var(--clr-base-strong); font-weight: 600; }
.status:empty { display: none; }

@media (max-height: 700px) { .pad { grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 64px); } .key { width: 64px; height: 64px; } }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
