.tsa-matcher {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.tsa-mg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tsa-mg-title {
  font-weight: 700;
}

.tsa-mg-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tsa-mg-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.tsa-mg-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tsa-mg-button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  background: #f3f4f6;
  color: #111827;
  padding: 6px 10px;
  cursor: pointer;
}
.tsa-mg-button:hover { background: #e5e7eb; }
.tsa-mg-button:active { background: #d1d5db; }
.tsa-mg-button.tsa-mg-danger { background: #fee2e2; }
.tsa-mg-button.tsa-mg-danger:hover { background: #fecaca; }

.tsa-mg-stage-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}

.tsa-mg-stage {
  --mg-bg: #0b1020;
  --mg-panel: #050816;
  --mg-accent: #94a3b8;
  --mg-grid: rgba(255, 255, 255, 0.08);
  --mg-highlight: #22d3ee;

  position: relative;
  background: var(--mg-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px;
  width: fit-content;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
}

.tsa-mg-grid {
  display: grid;
  grid-template-columns: repeat(28, 64px);
  grid-template-rows: repeat(12, 64px);
  gap: 0;
  background: var(--mg-panel);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.tsa-mg-cell {
  width: 64px;
  height: 64px;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  outline: 1px solid var(--mg-grid);
  outline-offset: -1px;
  transition: transform 120ms ease, opacity 120ms ease;
  user-select: none;
}

.tsa-mg-cell.is-selected {
  outline: 2px solid var(--mg-highlight);
  outline-offset: -2px;
}

.tsa-mg-cell.is-swapping {
  z-index: 3;
}

.tsa-mg-cell.is-clearing {
  opacity: 0;
  transform: scale(0.65);
}

.tsa-mg-icon {
  width: 64px;
  height: 64px;
  pointer-events: none;
  will-change: transform;
}

.tsa-matcher.is-paused .tsa-mg-cell {
  cursor: default;
}

.tsa-mg-pause-overlay {
  position: absolute;
  inset: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.92);
  font-size: 20px;
  letter-spacing: 0.4px;
}

.tsa-mg-pause-overlay.is-active {
  display: flex;
}

.tsa-mg-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  animation: tsa-mg-pop 700ms ease forwards;
  z-index: 5;
}

@keyframes tsa-mg-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(4px) scale(0.92); }
  15% { opacity: 1; transform: translate(-50%, -50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-14px) scale(1); }
}

.tsa-mg-status {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.75);
}

.tsa-mg-modal {
  border-radius: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.92);
}

.tsa-mg-modal h3 {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.tsa-mg-scores {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 10px;
}

.tsa-mg-scores th,
.tsa-mg-scores td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  text-align: left;
}

.tsa-mg-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
