.game-root {
  min-height: 32rem;
  display: flex;
  flex-direction: column;
}

.game-root.is-filled {
  overflow: auto;
  min-height: 0;
}

.spair-num {
  display: inline-block;
  min-width: 3ch;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.spair-new {
  min-width: 8.6rem;
  white-space: nowrap;
}

.spair-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  user-select: none;
  flex: 1 1 auto;
  min-height: 0;
  justify-content: center;
}

.spair-status {
  width: min(100%, 28rem);
  min-height: 5.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
  text-align: center;
}

.spair-line,
.spair-note,
.spair-audio {
  margin: 0;
  line-height: 1.35;
  min-height: 1.35em;
}

.spair-line { color: #f4f0e8; }

.spair-note {
  color: #d5ddd6;
  font-size: 0.95rem;
}

.spair-note.is-good { color: #e0b948; }

.spair-audio {
  color: #e0b948;
  font-size: 0.9rem;
}

.spair-board {
  --cols: 4;
  --rows: 4;
  --gap: clamp(0.4rem, 1.2cqw, 0.7rem);
  --card-max: 5.25rem;
  --card-min: var(--tap-min);
  --card-w: clamp(
    var(--card-min),
    calc((100cqw - 12px - var(--gap) * (var(--cols) - 1)) / var(--cols)),
    var(--card-max)
  );
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--card-w));
  gap: var(--gap);
  justify-content: center;
  width: 100%;
  padding: 4px;
  box-sizing: border-box;
}

.game-root.is-filled .spair-board {
  --card-max: min(5.25rem, calc((100dvh - 11rem) / var(--rows)));
}

.spair-cell {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  width: var(--card-w);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #1a2c24;
  box-shadow: inset 0 0 0 1px rgba(224, 185, 72, 0.28);
  color: #fffdf7;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.spair-cell.is-up {
  background: #efe6d4;
  box-shadow: inset 0 0 0 1px rgba(90, 62, 32, 0.35);
  color: #1d2433;
}

.spair-cell.is-open {
  box-shadow: inset 0 0 0 2px #e0b948;
}

.spair-cell.is-matched {
  background: #fffdf7;
  box-shadow: inset 0 0 0 2px #2e6b4e;
  cursor: default;
}

.spair-cell.is-colors {
  background: var(--tone, #fffdf7);
  color: #fffdf7;
  box-shadow: inset 0 0 0 2px rgba(29, 36, 51, 0.35);
}

.spair-cell.is-colors.is-matched {
  box-shadow: inset 0 0 0 3px #fffdf7;
}

.spair-cell:disabled {
  opacity: 1;
}

.spair-cell:focus-visible {
  outline: 3px solid #e0b948;
  outline-offset: 2px;
}

.spair-cell.is-flip {
  animation: spair-flip 260ms ease-out;
}

.spair-face {
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  line-height: 1;
}

@keyframes spair-flip {
  from { transform: scaleX(0.08); }
  to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  .spair-cell.is-flip { animation: none; }
}

@media (max-width: 640px) {
  .spair-new { min-width: 0; }
}
