.bm-match {
  width: min(660px, calc(100% - 36px));
  max-width: none;
  max-height: calc(100% - 40px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: #194b3a;
  background: #fcfbf5;
  border: 1px solid #d8ded2;
  border-radius: 28px;
  box-shadow: 0 20px 75px #153c3940;
  font-family: var(--font, ui-rounded, system-ui, sans-serif);
}
.bm-match::backdrop { background: #173b3299; }
.bm-match *, .bm-match *::before, .bm-match *::after { box-sizing: border-box; }
.bm-match button, .bm-match select { font: inherit; }
.bm-match button, .bm-match select { cursor: pointer; }
.bm-match button:focus-visible, .bm-match select:focus-visible {
  outline: 3px solid #af740d; outline-offset: 3px;
}
.bm-match h2:focus { outline: 0; }
.bm-match [hidden] { display: none !important; }
.bm-match-inner { padding: clamp(20px, 4vw, 32px); }
.bm-match-header { display: flex; align-items: center; gap: 14px; }
.bm-match-header h2 { color: #174835; font-size: clamp(1.5rem, 3.6vw, 2.05rem); line-height: 1.25; }
.bm-match-header p { margin: 6px 0 0; color: #5c7164; line-height: 1.55; font-size: 1rem; }
.bm-match-sign { display: grid; place-items: center; flex: none; width: 51px; height: 56px; border-radius: 15px; transform: rotate(-6deg); color: #394b76; background: #dae2fa; border: 2px solid #b8c7ee; box-shadow: -3px 3px #b6c5ea; }
.bm-match-sign svg { transform: rotate(6deg); }
.bm-match-x { display: grid; place-items: center; align-self: flex-start; flex: none; width: 44px; height: 44px; margin-left: auto; padding: 0; border: 1px solid #dbe2d4; border-radius: 50%; color: #537260; background: #f6f8ef; }
.bm-match-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block: 22px 13px; }
.bm-match-select, .bm-match-count { display: inline-flex; align-items: center; font-size: .92rem; }
.bm-match-select { position: relative; min-width: 0; }
.bm-match-select svg { position: absolute; pointer-events: none; color: #546b58; }
.bm-match-select svg:first-child { left: 11px; }
.bm-match-select svg:last-child { right: 11px; transform: rotate(90deg); }
.bm-match-select select { appearance: none; -webkit-appearance: none; min-height: 44px; max-width: 100%; padding: 7px 32px 7px 37px; color: #254e39; background: #eff4e9; border: 1px solid #d5dfcf; border-radius: 13px; font-weight: 730; }
.bm-match-count { flex-shrink: 0; gap: 5px; color: #50685a; }
.bm-match-count svg { color: #438454; }
.bm-match-count b { color: #244a35; font-size: 1rem; font-variant-numeric: tabular-nums; }
.bm-match-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.bm-match-card {
  position: relative; isolation: isolate; display: grid; align-content: center; justify-items: center;
  width: 100%; min-width: 0; height: clamp(94px, 15vh, 139px); padding: 10px 6px;
  color: #eaf1ff; background: #546ca6; background-image: radial-gradient(ellipse at 34% 8%, #849bd2, #607bb5 48%, #4e639b);
  border: 2px solid #526699; border-radius: 18px; box-shadow: 0 3px #404e79;
  transition: transform .16s, background-color .16s, box-shadow .16s;
}
.bm-match-card[data-state="down"]::before {
  content: ''; position: absolute; z-index: -1; inset: 5px; border: 1px solid #d3dff599; border-radius: 12px;
  background: radial-gradient(ellipse at 17% 25%, #f5da82 0 2px, transparent 2.6px),
    radial-gradient(ellipse at 80% 77%, #f5da82 0 2px, transparent 2.6px),
    radial-gradient(ellipse at 24% 68%, #c5d3fa 0 1.5px, transparent 2px),
    radial-gradient(ellipse at 77% 27%, #c5d3fa 0 1.8px, transparent 2.4px);
}
.bm-match-card[data-state="down"]::after { content: '✦'; position: absolute; right: 17%; top: 6%; color: #f0dfa0; font-size: 1rem; }
.bm-match-mark { display: grid; place-items: center; min-width: 48px; height: 54px; padding: 0 12px 2px; border: 1px solid #bbcbefad; border-radius: 50%; color: #fff5d7; font: 900 2.15rem/1 var(--latin, ui-rounded, sans-serif); text-shadow: 0 2px #455c91; transform: rotate(-6deg); }
.bm-match-card[data-state="up"], .bm-match-card[data-state="matched"] {
  gap: 4px; color: #394b76; background: #f4f2fb;
  border-color: #bdc6e0; box-shadow: 0 3px #a0abc9;
}
.bm-match-card[data-state="matched"] { color: #285b42; background: #e6f2df; border-color: #afcda7; box-shadow: 0 3px #94b78e; }
.bm-match-kind { font-size: .79rem; line-height: 1.2; font-weight: 650; color: #586788; }
.bm-match-card[data-state="matched"] .bm-match-kind { color: #47684e; }
.bm-match-card strong { max-width: 100%; line-height: 1.2; overflow-wrap: anywhere; font-size: clamp(1rem, 3.3vw, 1.3rem); }
.bm-match-card strong[lang="en"] { font-family: var(--latin, ui-rounded, sans-serif); }
.bm-match-tick { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: #54825a; }
.bm-match-feedback { min-height: 45px; display: flex; align-items: center; margin: 17px 0 6px; padding: 8px 13px; color: #4b6353; background: #f0f3e8; border-radius: 12px; font-size: .94rem; line-height: 1.45; }
.bm-match-success { color: #5e4a1c; background: #ffedb4; }
.bm-match-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.bm-match-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 6px 11px; border: 0; border-radius: 12px; color: #395c45; background: transparent; font-weight: 750; }
.bm-match-exit { padding: 7px 18px; background: #24573e; color: white; }
@media (hover: hover) {
  .bm-match-card:hover { transform: translateY(-2px); }
  .bm-match-button:not(.bm-match-exit):hover, .bm-match-x:hover { background: #eaf0e3; }
}
.bm-match-card:active { transform: translateY(2px); }
@media (max-width: 590px) {
  .bm-match { width: calc(100% - 20px); max-height: calc(100dvh - 20px); border-radius: 21px; }
  .bm-match-inner { padding: 16px; }
  .bm-match-header { gap: 10px; }
  .bm-match-sign { display: none; }
  .bm-match-header p { font-size: .93rem; }
  .bm-match-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .bm-match-card { height: clamp(65px, 10.5dvh, 100px); border-radius: 15px; }
  .bm-match-mark { min-width: 39px; height: 41px; font-size: 1.75rem; }
  .bm-match-tools { margin-block: 13px 10px; }
  .bm-match-feedback { margin-top: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .bm-match-card { transition: none; }
}
