:root {
  color-scheme: light;
  font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "BIZ UDPGothic", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: #3a2656;
  background: #fdf6ff;
  font-synthesis: none;
  --ink: #3a2656;
  --muted: #6e5a8a;
  --purple: #7a42c4;
  --pink: #e5539b;
  --gold: #f5c35b;
  --gold-deep: #d6982b;
  --line: #f0e2fa;
  --board-width: clamp(264px, calc((100svh - 205px) / 2), 330px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 300px;
  min-height: 100svh;
  background:
    radial-gradient(circle at 12% 18%, #ffe3f4 0%, transparent 34%),
    radial-gradient(circle at 88% 22%, #e4f3ff 0%, transparent 36%),
    radial-gradient(circle at 84% 80%, #fff2cf 0%, transparent 35%),
    radial-gradient(circle at 16% 82%, #ede0ff 0%, transparent 38%),
    radial-gradient(circle, #d4a8f033 1.5px, transparent 1.7px) 0 0 / 24px 24px,
    linear-gradient(160deg, #fff6fb 0%, #f6efff 52%, #effaff 100%);
}

ruby { ruby-align: center; }
rt { font-size: 0.62em; color: #7e5ba8; font-weight: 700; }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible {
  outline: 3px solid #f078b8;
  outline-offset: 4px;
}
h1, h2, p, dl, dd, ul { margin: 0; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(24px, calc((100% - 1140px) / 2));
  background: linear-gradient(90deg, #ffffffea, #fff7fcea, #f9f4ffea);
  border-bottom: 2px solid #f2defa;
  box-shadow: 0 4px 16px #b57ae614;
  backdrop-filter: blur(8px);
}
.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  font-size: 1.25rem;
  font-weight: 900;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: -.03em;
}
.brand-accent {
  background: linear-gradient(135deg, #8b4be0, #e85ca5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-ribbon {
  font-size: .72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe2f1, #f3e4ff);
  color: #9e3f87;
  border: 1px solid #f5c6e3;
  box-shadow: 0 2px 0 #eab8da;
}
.brand-mark { display: grid; grid-template-columns: repeat(2, 11px); gap: 3px; transform: rotate(-10deg); }
.brand-mark i {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  background: #b18ef7;
  box-shadow: inset 0 2px #ffffff99;
}
.brand-mark i:nth-child(2) { background: #ffc266; }
.brand-mark i:nth-child(3) { background: #6fe3c1; }
.brand-mark i:nth-child(4) { background: #ff94c2; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  transition: background .18s, transform .15s, box-shadow .18s;
}
.button:active { transform: translateY(2px); }

.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #7c3b88;
  background: linear-gradient(180deg, #fff7fb, #fce6f5);
  border: 1.5px solid #f5c4e4;
  box-shadow: 0 3px 0 #eab4d8;
  padding: 8px 13px;
  font-size: .86rem;
  white-space: nowrap;
}
.sound-button:hover { background: linear-gradient(180deg, #fff, #fad9ef); }
.sound-button[aria-pressed="false"] {
  color: #766b85;
  background: #f3eff7;
  border-color: #dfd7ea;
  box-shadow: 0 3px 0 #cfc5de;
}

.settings-button {
  color: #5d3298;
  background: linear-gradient(180deg, #f8f2ff, #ece0ff);
  border: 1.5px solid #dcc5fc;
  box-shadow: 0 3px 0 #c8aef0;
  padding: 8px 14px;
  font-size: .875rem;
  white-space: nowrap;
}
.settings-button span { margin-right: 3px; font-size: 1rem; }
.settings-button:hover { background: linear-gradient(180deg, #fff, #e3d1ff); }

.arcade {
  display: grid;
  grid-template-columns: minmax(218px, 260px) auto minmax(218px, 260px);
  align-items: start;
  justify-content: center;
  column-gap: clamp(18px, 3vw, 40px);
  max-width: 1140px;
  margin: 0 auto;
  padding: 26px 24px 32px;
}
.left-rail, .right-rail { display: grid; gap: 14px; }

.card {
  min-width: 0;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #f2e2fc;
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 5px 0 #ead6f990, 0 12px 28px #8648b812;
  backdrop-filter: blur(4px);
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: .96rem;
  font-weight: 850;
}
.score-header, .next-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.combo-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff7eb6, #ffb36b);
  color: #fff;
  font-size: .76rem;
  font-weight: 900;
  box-shadow: 0 2px 6px #ff7eb666;
  animation: pop-bounce .45s cubic-bezier(.25, 1.5, .5, 1);
}
.assist-pill {
  font-size: .73rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff0b8, #ffd6e9);
  color: #9e426e;
  border: 1px solid #f7b8d8;
}

.tile, .reward-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 33px;
  height: 33px;
  border-radius: 11px;
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: inset 0 2px #ffffffb3, 0 2px 0 #0000000d;
}
.yellow { color: #8c5608; background: linear-gradient(180deg, #fff5d6, #ffe39f); }
.lilac { color: #6a44b3; background: linear-gradient(180deg, #f4edff, #e3d2ff); }
.mint { color: #1f785e; background: linear-gradient(180deg, #e7fcf4, #c6f5e3); }
.pink { color: #a83572; background: linear-gradient(180deg, #ffedf6, #ffd2e9); }

.score-number {
  display: block;
  background: linear-gradient(180deg, #7c3aed, #d9468f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Segoe UI", sans-serif;
  font-size: clamp(2.25rem, 3.8vw, 3.45rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -.05em;
  margin-top: 8px;
  overflow-wrap: anywhere;
  filter: drop-shadow(0 2px 0 #f5defc);
}
.record {
  width: fit-content;
  max-width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 7px 0 11px;
  padding: 4px 10px;
  background: linear-gradient(90deg, #fdf3ff, #fff3f8);
  border: 1px solid #f2d9fa;
  color: #6f459e;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.stat-list { display: grid; gap: 7px; padding-top: 11px; border-top: 1.5px dashed var(--line); }
.stat-list div, .keyboard-guide div { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.stat-list div { min-height: 26px; color: var(--muted); font-size: .875rem; font-weight: 700; }
.stat-list output { color: var(--ink); font-weight: 850; }
.stat-list .speed-badge {
  color: #1f6b52;
  background: #dff9ee;
  border: 1px solid #bcefd8;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .78rem;
}

/* マスコットカード */
.mascot-card {
  background: linear-gradient(145deg, #fff8fc, #f8f2ff);
  border-color: #f5d4ee;
  padding: 13px 15px;
  transition: background .3s, border-color .3s, transform .25s;
}
.mascot-stage {
  display: flex;
  align-items: center;
  gap: 14px;
}
.mascot-floating {
  position: relative;
  width: 74px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: none;
  background: radial-gradient(circle, #ffffff 0%, #f9e6ff 75%);
  border-radius: 16px;
  border: 1.5px solid #f1d4fa;
  box-shadow: inset 0 2px 6px #e9c9f866;
}
.mascot-floating .spark {
  position: absolute;
  font-size: 13px;
  line-height: 1;
}
.mascot-floating .m-one { left: 5px; top: 5px; color: #ffbf47; }
.mascot-floating .m-two { right: 6px; top: 5px; color: #ff79b0; }
.live-mascot {
  transform: rotate(-8deg) scale(0.92);
  transition: transform .25s ease;
}
.mascot-speech {
  min-width: 0;
  flex: 1;
}
.mascot-speech strong {
  display: inline-block;
  font-size: .75rem;
  color: #9b4dca;
  background: #f2e4ff;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.mascot-speech p {
  font-size: .84rem;
  font-weight: 800;
  color: #4a2e6b;
  line-height: 1.45;
}
.mascot-card[data-mood="happy"] {
  background: linear-gradient(145deg, #fff4fb, #fff9e6);
  border-color: #ffadd6;
}
.mascot-card[data-mood="happy"] .live-mascot {
  animation: mascot-jump .55s ease infinite alternate;
}
.mascot-card[data-mood="happy"] .live-mascot i {
  background: #ff9ec9;
  box-shadow: inset 0 3px #ffd9ec, inset 0 -3px #d96b9e;
}
.mascot-card[data-mood="pinch"] {
  background: linear-gradient(145deg, #fff3f6, #ffecf2);
  border-color: #ff9ebc;
}
.mascot-card[data-mood="pinch"] .live-mascot {
  animation: mascot-wobble .45s ease-in-out infinite alternate;
}
.mascot-card[data-mood="pinch"] .live-mascot b::after {
  border-width: 1.5px 0 0;
  top: 4px;
}

@keyframes mascot-jump {
  from { transform: translateY(0) rotate(-10deg) scale(0.92); }
  to { transform: translateY(-6px) rotate(8deg) scale(1.02); }
}
@keyframes mascot-wobble {
  from { transform: translateX(-2px) rotate(-12deg) scale(0.92); }
  to { transform: translateX(2px) rotate(-2deg) scale(0.92); }
}
@keyframes pop-bounce {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

.help-card p { margin: 9px 0; color: var(--muted); font-size: .85rem; line-height: 1.6; font-weight: 600; }
.keyboard-guide div { min-height: 33px; border-top: 1px solid #f4ecf9; font-size: .86rem; font-weight: 700; }
.keyboard-guide dd { display: flex; gap: 4px; }
kbd {
  min-width: 24px;
  padding: 2px 6px;
  display: inline-block;
  text-align: center;
  font: 800 .78rem/1.3 system-ui, sans-serif;
  color: #633d91;
  background: linear-gradient(180deg, #fff, #f5ecff);
  border: 1px solid #dec9f7;
  border-bottom-width: 2px;
  border-radius: 6px;
}

/* 魔法のコンパクト・おもちゃの筐体風 .machine */
.machine {
  position: relative;
  width: max-content;
  padding: 6px 15px 4px;
  color: #533473;
  background:
    linear-gradient(160deg, #ffd9ec 0%, #f3d5ff 48%, #d9ecff 100%);
  border: 3px solid #f3c164;
  border-radius: 30px;
  box-shadow:
    inset 0 3px 0 #ffffffcc,
    inset 0 -4px 0 #d9a7eb,
    0 8px 0 #cfa055,
    0 18px 38px #8c4bb838;
  transition: box-shadow .3s, border-color .3s;
}
.machine::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1.5px dashed #ffffffaa;
  border-radius: 24px;
  pointer-events: none;
}

.machine-crown {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding-top: 3px;
}
.gem {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #f5c76b;
  box-shadow: inset 0 2px 2px #ffffffcc, 0 2px 5px #0000001a;
}
.gem-pink { background: radial-gradient(circle at 35% 35%, #fff0f7, #ff6bae 65%, #c93077); }
.gem-yellow {
  width: 17px;
  height: 17px;
  background: radial-gradient(circle at 35% 35%, #fffce8, #ffd447 65%, #d68f15);
  box-shadow: inset 0 2px 3px #fff, 0 0 10px #ffd44799;
}
.gem-cyan { background: radial-gradient(circle at 35% 35%, #effdff, #5be3f5 65%, #239eb3); }

.machine-top {
  position: relative;
  display: flex;
  height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  gap: 8px;
}
.game-status {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: #5b3582;
  background: #ffffffbf;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid #eed6fb;
  font-size: .84rem;
  font-weight: 800;
}
.game-status i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3cd499;
  box-shadow: 0 0 8px #3cd499;
}
.machine[data-phase="paused"] .game-status i { background: #ffb84d; box-shadow: 0 0 8px #ffb84d; }
.machine[data-phase="over"] .game-status i { background: #ff7aa8; box-shadow: 0 0 8px #ff7aa8; }

.pinch-alert {
  font-size: .76rem;
  font-weight: 900;
  color: #a8235f;
  background: linear-gradient(90deg, #ffe3ef, #fff1c2);
  border: 1.5px solid #ff8ab8;
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: 0 0 10px #ff8ab866;
  animation: pinch-pulse .8s ease-in-out infinite alternate;
}
@keyframes pinch-pulse {
  from { transform: scale(0.96); background: #ffe3ef; }
  to { transform: scale(1.04); background: #fff0c7; }
}

.pause-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 31px;
  color: #673996;
  background: linear-gradient(180deg, #fff, #f2e3ff);
  border: 1.5px solid #d9baf7;
  box-shadow: 0 2px 0 #c6a4eb;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 900;
}
.pause-button:disabled { opacity: .5; }
.pause-button:hover:enabled { background: #fff; }

.playfield {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 16px;
  border: 3px solid #f4c66d;
  background: #2b1f47;
  box-shadow: inset 0 0 16px #180e2e80, 0 2px 0 #ffffff99;
  transition: border-color .3s, box-shadow .3s;
}
.machine[data-pinch="true"] .playfield {
  border-color: #ff82b2;
  box-shadow: inset 0 0 18px #ff70a655, 0 0 16px #ff82b288;
}
.machine[data-rainbow-flash="true"] .playfield {
  animation: rainbow-border 0.35s linear infinite;
}
@keyframes rainbow-border {
  0% { border-color: #ff7eb6; box-shadow: 0 0 22px #ff7eb6; }
  25% { border-color: #ffd86b; box-shadow: 0 0 22px #ffd86b; }
  50% { border-color: #72efdd; box-shadow: 0 0 22px #72efdd; }
  75% { border-color: #b58cff; box-shadow: 0 0 22px #b58cff; }
  100% { border-color: #ff7eb6; box-shadow: 0 0 22px #ff7eb6; }
}

#board { width: var(--board-width); height: auto; display: block; }

.machine-bottom {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.machine-bottom i {
  width: 16px;
  height: 4px;
  border-radius: 5px;
  background: #ffffffbf;
  border: 1px solid #e1bef5;
}
.machine-bottom i:nth-child(3) { background: #ffd86b; border-color: #e6ac35; }
.heart-gem {
  color: #ff69a6;
  font-size: .85rem;
  text-shadow: 0 1px 0 #fff;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 17px;
  background: radial-gradient(ellipse at 50% 43%, #4d327078, #24173be6 78%);
  backdrop-filter: blur(3px);
}
.welcome {
  width: 100%;
  max-width: 268px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, #fff9fd, #f6ebff);
  border: 3px solid #f4c66d;
  border-radius: 24px;
  padding: 22px 14px 18px;
  text-align: center;
  box-shadow: 0 12px 30px #150b2988, inset 0 2px 0 #fff;
}
.welcome-art { position: relative; display: grid; place-items: center; width: 132px; height: 76px; margin-bottom: 8px; }
.mascot {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 20px);
  grid-template-rows: repeat(2, 20px);
  gap: 2px;
  transform: rotate(-13deg) scale(1.22);
  filter: drop-shadow(0 5px 0 #bd9be080);
}
.mascot i {
  display: block;
  border-radius: 6px;
  background: #b794f6;
  box-shadow: inset 0 3px #ebd9ff, inset 0 -3px #8e66d6;
}
.mascot i:first-child { grid-column: 2; }
.mascot i:nth-child(2) { grid-column: 1; grid-row: 2; }
.mascot i:nth-child(3) { grid-column: 2; grid-row: 2; }
.mascot i:nth-child(4) { grid-column: 3; grid-row: 2; }
.mascot b {
  position: absolute;
  left: 26px;
  bottom: 8px;
  width: 3.5px;
  height: 4.5px;
  background: #34224f;
  border-radius: 50%;
  box-shadow: 9px 0 #34224f, -3px 4px #ff8ec6, 12px 4px #ff8ec6;
}
.mascot b::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 4px;
  left: 3.5px;
  top: 3px;
  border: solid #34224f;
  border-width: 0 0 1.4px;
  border-radius: 50%;
}
.spark { position: absolute; line-height: 1; }
.spark.one { left: 8px; top: 8px; color: #ffb938; font-size: 26px; }
.spark.two { right: 10px; bottom: 5px; color: #ff70b5; font-size: 21px; }
.spark.three { right: 18px; top: 8px; color: #5cd6b3; font-size: 15px; }

.welcome h1 {
  color: #7c38b8;
  font-size: clamp(1.65rem, 4.6vw, 2.1rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: .02em;
  text-shadow: 0 2px 0 #f6d5ff;
}
.welcome p { margin-top: 10px; color: #644882; font-size: .88rem; font-weight: 700; line-height: 1.55; }
.primary-button {
  background: linear-gradient(180deg, #ff8ac4, #e8529c);
  color: #fff;
  padding: 11px 16px;
  border: 1.5px solid #ffadd6;
  box-shadow: 0 4px 0 #bf3579, 0 6px 14px #e8529c4d;
  text-shadow: 0 1px 1px #a62564;
}
.primary-button:hover { background: linear-gradient(180deg, #ff9bce, #f060a7); }
.welcome .primary-button { margin-top: 16px; padding: 12px 14px; width: 100%; max-width: 215px; font-size: .96rem; }
.start-hint { display: inline-flex; align-items: center; gap: 5px; margin-top: 13px; font-size: .8rem; font-weight: 700; color: #7a5c99; }
.text-button { border: 0; background: transparent; color: var(--purple); padding: 7px 0; font-weight: 800; }
.text-button:hover { text-decoration: underline; }
.welcome .text-button { margin-top: 8px; color: #874bc2; font-size: .86rem; }

.preview {
  margin-top: 12px;
  overflow: hidden;
  border: 2px solid #f0dffb;
  border-radius: 15px;
  background:
    radial-gradient(circle, #e5d2f7 1.2px, transparent 1.4px) 4px 4px / 14px 14px,
    linear-gradient(180deg, #fdfaff, #f8f0ff);
  box-shadow: inset 0 2px 6px #e6d1f74d;
}
#next { display: block; width: 100%; height: auto; }

.rewards { display: grid; list-style: none; padding: 0; margin-top: 9px; }
.rewards li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 9px;
  padding: 8px 0;
  min-height: 46px;
  font-size: .875rem;
}
.rewards li + li { border-top: 1.5px dashed #f2e8fa; }
.rewards li:last-child { padding-bottom: 0; }
.reward-icon { width: 32px; height: 32px; }
.stars { color: #9c6209; background: linear-gradient(180deg, #fff5d6, #ffe39e); }
.flowers { color: #ad3473; background: linear-gradient(180deg, #ffebf4, #ffd0e7); }
.rainbow { background: linear-gradient(180deg, #e8fcf4, #c9f5e3); }
.party { background: linear-gradient(180deg, #f3ebff, #e2d0ff); }
.rewards strong, .rewards small { display: block; }
.rewards small { color: var(--muted); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.rewards li b { color: #c83e8b; font-size: .96rem; font-weight: 900; white-space: nowrap; }
.rewards li b span { font-size: .75rem; margin-left: 2px; }

.controller-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  color: #4f3173;
  border: 2px solid #e7d2fc;
  border-radius: 18px;
  background: linear-gradient(135deg, #f6efff, #fff0f8);
  box-shadow: 0 4px 0 #e5cef980;
}
.controller-symbol {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 31px;
  border-radius: 10px;
  background: #e1cdfc;
  color: #613ea9;
  font-size: 1.05rem;
  box-shadow: inset 0 2px #ffffffa6;
}
.controller-note strong { display: block; font-size: .875rem; }
.controller-note p { margin-top: 3px; font-size: .83rem; font-weight: 600; line-height: 1.5; }

/* コントローラー設定ダイアログ */
.controls-dialog {
  width: min(530px, calc(100vw - 28px));
  max-height: calc(100svh - 36px);
  padding: 22px;
  border: 3px solid #f2c36b;
  border-radius: 26px;
  background: linear-gradient(180deg, #fffbfd, #f9f2ff);
  color: var(--ink);
  box-shadow: 0 20px 65px #22103666;
}
.controls-dialog::backdrop { background: #26163b9e; backdrop-filter: blur(3px); }
.dialog-heading, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-heading h2 { font-size: 1.22rem; color: #6c35a3; }
.dialog-lead {
  margin-top: 6px;
  font-size: .88rem;
  font-weight: 800;
  color: #b84283;
}
.icon-button {
  border: 0;
  border-radius: 10px;
  background: #f2e6fc;
  color: var(--ink);
  font-size: 1.3rem;
  width: 35px;
  height: 35px;
  flex: none;
}
.setup-steps {
  margin: 10px 0 12px;
  padding-left: 1.3rem;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.65;
}
.setup-steps li + li { margin-top: 3px; }

/* 8BitDo Micro 視覚モニター */
.controller-monitor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef6ff, #f9edff);
  border: 2px solid #d9c4f7;
  transition: transform .15s, border-color .2s, background .2s;
}
.controller-monitor.is-active {
  border-color: #ff79b0;
  background: linear-gradient(135deg, #fff0f7, #fff8d9);
  transform: scale(1.015);
}
.monitor-pad {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #7796f5;
  color: #fff;
  font-size: .76rem;
  font-weight: 900;
  box-shadow: inset 0 2px #a6bcff, 0 3px 0 #516ec9;
  flex: none;
}
.pad-dpad, .pad-abxy { font-size: .85rem; opacity: .95; }
.monitor-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: .84rem;
}
.monitor-caption { color: var(--muted); font-weight: 700; }
.monitor-key {
  padding: 3px 10px;
  border-radius: 8px;
  background: #fff;
  color: #8238b8;
  border: 1.5px solid #DFC5FA;
  font-size: .85rem;
}

.binding-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  min-height: 47px;
  padding: 4px 6px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 750;
  transition: background .2s;
}
.binding-row.is-pressed {
  background: #fff0f8;
}
.binding-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f3e8ff;
  color: #703ca8;
  font-size: .95rem;
}
.binding-row kbd { min-width: 52px; }
.binding-row button {
  color: #5d3298;
  background: #f1e7fd;
  border: 1px solid #d9c2f7;
  padding: 5px 11px;
  font-size: .83rem;
}
.binding-row button:hover, .binding-row button[aria-pressed="true"] {
  background: #ff85bc;
  color: #fff;
  border-color: #e65c9c;
}
.binding-status {
  min-height: 2.3rem;
  padding-top: 8px;
  color: #9e3375;
  font-size: .86rem;
  font-weight: 800;
}
.dialog-actions .primary-button { min-width: 110px; padding: 9px 16px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 940px) {
  .arcade { grid-template-columns: minmax(185px, 232px) auto minmax(185px, 232px); gap: 14px; padding-inline: 15px; }
  .card { padding: 13px; }
}
@media (max-width: 730px) {
  .arcade { grid-template-columns: repeat(2, minmax(0, 250px)); gap: 14px; padding-top: 20px; }
  .machine { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
  .left-rail { grid-column: 1; }
  .right-rail { grid-column: 2; }
}
@media (max-width: 440px) {
  .topbar { padding-inline: 10px; gap: 6px; }
  .brand { font-size: .98rem; gap: 6px; }
  .brand-ribbon { display: none; }
  .sound-button, .settings-button { padding: 7px 9px; font-size: .76rem; }
  .arcade { grid-template-columns: minmax(0, 1fr); }
  .left-rail, .right-rail { grid-column: 1; }
  .machine { max-width: 100%; }
  #board { width: min(var(--board-width), calc(100vw - 58px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
