.family-match {
  --fm-line: #b596627a;
  --fm-soft: #eadaba;
  --fm-paper: #f3e2bd;
  --fm-green: #25423a;
  display: grid;
  gap: clamp(.65rem, 2vw, 1rem);
  min-width: 0;
  padding: clamp(.85rem, 3vw, 1.65rem);
  border: 1px solid var(--fm-line);
  border-radius: 9px;
  color: #fff3da;
  background: radial-gradient(ellipse at 58% 0%, #30483e, #203630 62%, #1a2b29);
  box-shadow: inset 0 0 0 4px #1a2d297a;
}

.family-match [hidden] { display: none; }
.fm-modes, .fm-scores { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }

.fm-mode, .fm-replay, .fm-choice {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.fm-mode, .fm-replay {
  min-height: 44px;
  padding: .36rem .7rem;
  border: 1px solid var(--fm-line);
  border-radius: 5px;
  background: #1d342e;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.2;
}

.fm-mode:hover, .fm-replay:hover { background: #375246; }
.fm-mode[aria-pressed="true"] { color: #25332b; background: var(--fm-paper); border-color: #daba77; }

.family-match :is(button):focus-visible {
  outline: 2px solid #fed682;
  outline-offset: 3px;
}

.fm-prompt {
  margin: 0;
  color: var(--fm-soft);
  max-width: 60ch;
}

.fm-scores {
  min-height: 44px;
  padding-bottom: .65rem;
  border-bottom: 1px solid #e0bf8452;
}

.fm-score {
  padding: .15rem .5rem;
  border: 1px solid #c7a36a55;
  border-radius: 4px;
  background: #1a2c2a;
  color: var(--fm-soft);
  font-size: .86rem;
  font-variant-numeric: tabular-nums;
}

.fm-replay { margin-left: auto; }
.fm-decks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(.55rem, 2.8vw, 1.5rem); }
.fm-deck { min-width: 0; }
.fm-deck-title { margin: 0 0 .55rem; color: var(--fm-soft); font: 600 1.2rem/1.1 Georgia, serif; }
.fm-deck-list { margin: 0; padding: 0; display: grid; gap: .48rem; list-style: none; }

.fm-choice {
  position: relative;
  width: 100%;
  min-height: 65px;
  display: flex;
  align-items: center;
  gap: clamp(.3rem, 2vw, .7rem);
  padding: .43rem .55rem;
  border: 1px solid #cbb28480;
  border-radius: 6px;
  text-align: left;
  background: linear-gradient(125deg, #31463c, #233732);
}

.fm-choice:enabled:hover { background: #3b5548; border-color: #f4c980; }
.fm-choice[data-state="selected"] { background: #584b35; border-color: #ffd18a; box-shadow: inset 0 0 0 1px #d3a96274; }
.fm-choice[data-state="wrong"] { background: #593638; border-color: #d98b7d; }
.fm-choice[data-state="matched"] { background: #335247; border-color: #91b195; cursor: auto; color: #eee3c8; }
.fm-choice:disabled { opacity: 1; }
.fm-choice-copy { display: grid; align-content: center; min-width: 0; padding-block: .12rem; }
.fm-choice strong { font: 700 clamp(.99rem, 2.3vw, 1.22rem)/1.16 Georgia, serif; overflow-wrap: anywhere; }
.fm-detail { margin-top: .2rem; color: var(--fm-soft); font-size: .82rem; line-height: 1.27; overflow-wrap: anywhere; }
.fm-face {
  display: grid;
  overflow: hidden;
  flex: 0 0 auto;
  width: clamp(35px, 6vw, 50px);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid #d8b382;
  border-radius: 50%;
  background: var(--fm-green);
}
.fm-face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fm-face:is([data-person="aj"], [data-person="jenni"]) img { transform: scale(1.78); transform-origin: 50% 22%; }

.fm-check {
  display: none;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0 .25rem;
  color: #ddf1cd;
  font-weight: 700;
}
.fm-choice[data-state="matched"] .fm-check { display: inline; }

.fm-feedback {
  margin: 0;
  min-height: 2.55rem;
  padding: .46rem .64rem;
  border-left: 2px solid #c9a36a;
  background: #17332b;
  color: #fff1d5;
  font-size: .94rem;
}

.fm-feedback[data-result="complete"] { color: #e8f2d3; border-color: #a6c597; font-weight: 700; }
.fm-feedback[data-result="retry"] { border-color: #d78b7d; }

@media (max-width: 425px) {
  .family-match { padding-inline: .62rem; }
  .fm-choice { padding-inline: .34rem; }
  .fm-choice .fm-check { position: absolute; inset: .12rem .14rem auto auto; font-size: .7rem; }
  .fm-choice[data-state="matched"] .fm-choice-copy { padding-right: .54rem; }
  .fm-score { padding-inline: .38rem; }
  .fm-replay { padding-inline: .52rem; }
}
